WordPress.org

Ready to get started?Download WordPress

Forums

Header title (5 posts)

  1. Anonymous
    Unregistered
    Posted 6 years ago #

    Hello,

    I have a question about the <title> tag. What can I do to let people see on what page of the website they are? Something like this:

    Home - My website
    Blog - My website

    <title>(page title) - Title website</title>

    What kind of codes do I have to use? I hope I'm clear.

    Regards,

  2. educationthemes
    Member
    Posted 6 years ago #

    I think you will need to be a little more clear what you mean. Are you talking about in header.php and what shows at the top of your browser window?

  3. Anonymous
    Unregistered
    Posted 6 years ago #

    Yes, that's what I'm trying to explain.

  4. Dan.F
    Member
    Posted 6 years ago #

    do you mean this:
    <title><?php bloginfo('name'); ?><?php wp_title(); ?></title>

    maybe try this:
    http://wpcandy.com/articles/tutorials/the-wordpress-help-sheet.html

  5. chaoskaizer
    Member
    Posted 6 years ago #

    add the below code inside your functions.php, I assume your theme header.php has do_action('wp_head') action filters.

    function my_custom_blog_title(){
    
    	$blogname  = $output = get_option('blogname');
    	$separator = ' &#187 '; // raquo >> chars		
    
    	if (is_home()):
    		$output .= wp_title($separator,false,'left');
    
    	elseif (is_search()):
    		$output  = sprintf(__('%1$s - Search results for: %2$s'),$blogname, wp_specialchars(get_query_var('s'), 1));
    
    	elseif(is_404()):
    		$output  .= __(' 404 Error: Page not found');
    
    	else:
    		$output = wp_title($separator,false,'right').$blogname;
    
    	endif;
    
    	$output = '<title>'.$output.'</title>'.PHP_EOL;
    
    	echo apply_filters('my_custom_blog_title', $output);
    }	
    
    add_action('wp_head','my_custom_blog_title');

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags