Remove site name from <title> tag

My current <title> tags are like this:

Blog post title | Site name

Read More

How do I remove “Site name” so that the <title> tags will be like this:

Blog post title

Except, of course, on the front page, where the <title> tag should be:

Site name

Please take into account that I’m a complete WordPress newbie.


Edit: Here’s my current <title> tag from header.php:

<title>
<?php
if ( defined( 'WPSEO_VERSION' ) ) {
    // WordPress SEO is activated
        wp_title();

} else {

    // WordPress SEO is not activated
    wp_title( '|', true, 'right' );
}
?>
</title>

Related posts

Leave a Reply

6 comments

  1. The best (and easiest) thing to do is to use the wp_title filter.

    First, clean up your call to <?php wp_title(); ?> in your template. Replace what you have with this:

     wp_title( '&#124;', true, 'right' );
    

    Then, in functions.php (or in a child Theme functions.php; normal caveats apply), add the following:

    function wpse95147_filter_wp_title( $title ) {
        if ( is_single() || ( is_home() && !is_front_page() ) || ( is_page() && !is_front_page() ) ) {
            $title = single_post_title( '', false );
        }
        return $title;
    }
    add_filter( 'wp_title', 'wpse95147_filter_wp_title' );
    

    This filter will completely overwrite the $title output in single-page contexts. (The actual conditional is taken directly from core, from the wp_title() function definition itself.)

    Last I checked, WordPress doesn’t actually output the site title anywhere in wp_title(); so if you’re seeing that, something is adding it (perhaps your Theme?). Nevertheless, if you want to output it, just write a complimentary conditional in the above filter; e.g.:

    function wpse95147_filter_wp_title( $title ) {
        if ( is_single() || ( is_home() && !is_front_page() ) || ( is_page() && !is_front_page() ) ) {
            $title = single_post_title( '', false );
        }
        if ( is_front_page() && ! is_page() ) {
            $title = esc_attr( get_bloginfo( 'name' ) );
        }
        return $title;
    }
    add_filter( 'wp_title', 'wpse95147_filter_wp_title' );
    
  2. Add this line in your header.php file

    <title><?php wp_title();?></title>
    

    Add Below code in theme’s functions.php file

    function your_wp_title( $title, $sep ) {
        global $paged, $page;
        if(is_front_page()){        
            $title = get_bloginfo( 'name' );   
            return $title;
        } else {
            if ( is_feed() )            
            // Add the site name.
            return $title;
        }
    }
    add_filter( 'wp_title', 'your_wp_title', 10, 2 );
    

    Reference:http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_title

  3. On my template file header.php I replaced the title line by this

    <title><?php is_front_page() ? woo_title() : wp_title( '' ); ?></title>
    

    In my case I am using a woothemes template, that’s why that woo_title() output.

    Here, you can check in a single line if you are on home page, if true, you can allow to display the blog/site title, if false output the title without the site name, just will display your post or page title.

  4. i was haveing this issue with posts so i searched the interet and i made a little plugin that remove the blog name from the posts

    ########### start remove blog title from posts #######
     function wp_abdul0201_wp_title( $title ) {
        if ( is_single() ) {
            $title = single_post_title( '', false );
        }
        return $title;
    }
    add_filter( 'pre_get_document_title', 'wp_abdul0201_wp_title' );
    ########### end remove blog title from posts #######
    

    please notince this code

    if ( is_single() )
    

    it only applies to posts title
    you can add more codition like

    if ( is_single() || is_archive ) 
    

    here i added archive pages too
    i hope you got a general idea of how it works

  5. <?php wp_title(false); ?>
    

    Try this and also read more here

    &#124;indicates vertical bar as separator. true argument stands for $display, whether to display the title or no. Third arugment is position where to put separator.