This topic has 5 replies, 5 voices, and was last updated 8 years by rikbutterflyskull.

  • Author
  • #15829
     Abe
    Keymaster

    For KLEO we have created a function that generates the titles for all WordPress specific pages. You just need to redefine this function in your child theme/functions.php and rename the strings. Make sure to have the child theme activated.

    COPY CODE
    
    //Add me to child theme functions.php
    function kleo_title()
    {
    	$output = "";
    
    	if ( is_category() )
    	{
    		$output = __('Archive for category:','kleo_framework')." ".single_cat_title('',false);
    	}
    	elseif (is_day())
    	{
    		$output = __('Archive for date:','kleo_framework')." ".get_the_time('F jS, Y');
    	}
    	elseif (is_month())
    	{
    		$output = __('Archive for month:','kleo_framework')." ".get_the_time('F, Y');
    	}
    	elseif (is_year())
    	{
    		$output = __('Archive for year:','kleo_framework')." ".get_the_time('Y');
    	}
    	elseif (is_search())
    	{
    		global $wp_query;
    		if(!empty($wp_query->found_posts))
    		{
    			if($wp_query->found_posts > 1)
    			{
    				$output =  $wp_query->found_posts ." ". __('search results for:','kleo_framework')." ".esc_attr( get_search_query() );
    			}
    			else
    			{
    				$output =  $wp_query->found_posts ." ". __('search result for:','kleo_framework')." ".esc_attr( get_search_query() );
    			}
    		}
    		else
    		{
    			if(!empty($_GET['s']))
    			{
    				$output = __('Search results for:','kleo_framework')." ".esc_attr( get_search_query() );
    			}
    			else
    			{
    				$output = __('To search the site please enter a valid term','kleo_framework');
    			}
    		}
    
    	}
    	elseif (is_author())
    	{
    		$curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
    		$output = __('Author Archive','kleo_framework')." ";
    
    		if(isset($curauth->nickname)) $output .= __('for:','kleo_framework')." ".$curauth->nickname;
    
    	}
    	elseif (is_tag())
    	{
    		$output = __('Tag Archive for:','kleo_framework')." ".single_tag_title('',false);
    	}
    	elseif(is_tax())
    	{
    		$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
    		$output = __('Archive for:','kleo_framework')." ".$term->name;
    
    	} elseif ( is_front_page() && !is_home() ) {
    					$output = get_the_title(get_option('page_on_front'));
    
    	} elseif ( is_home() && !is_front_page() ) {
    					$output = get_the_title(get_option('page_for_posts'));
    
    	} elseif ( is_404() ) {
    					$output = __('Error 404 - Page not found','kleo_framework');
    	}
    	else {
    		$output = get_the_title();
    	}
    
    	if (isset($_GET['paged']) && !empty($_GET['paged']))
    	{
    		$output .= " (".__('Page','kleo_framework')." ".$_GET['paged'].")";
    	}
    
    	return $output;
    }
    

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #30402
     Abe
    Keymaster

    Hi @sachaf
    Right now you can translate the Portfolio string from the theme, even though your language used is English this is a method the replace theme strings without changing theme files

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #38144
     Sebastien789
    Participant

    Hi,

    Sorry but i don’t understand what do I have to “rename” ? I don’t know what is “string” ?
    When I copy/past this code on the php file, it doesn’t works. What do i have to rename please ?

    #64925
     felixodeli
    Participant

    I removed “Archive for category:” from line 8 and it worked

    #71465
     ShauntiG
    Participant

    Is this the correct syntax for removing the Archive for category text and where in the child theme functions do I place the code? I got a syntax error (WSOD) and had call my host to fix. Please help, still need to remove the Archive text. https://socialbilitty.com

    {
    $output = __(‘Archive for category:’,’kleo_framework’).” “.single_cat_title(”,false);
    }

    #102524
     rikbutterflyskull
    Participant

    @Abe is the same as using the .po files?

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Change KLEO page title for archives and other wordpress pages’ is closed to new replies.

Log in with your credentials

Forgot your details?