Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

My current <title> tags are like this:

Blog post title | Site name

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( '&#124;', true, 'right' );
}
?>
</title>
share|improve this question
    
If you have any SEO plugin active, try to find its title settings. If not, tell us. :) –  toscho Apr 9 '13 at 12:36
    
I don't have any SEO plugins active. –  Miscreant Apr 9 '13 at 12:39
1  
Then why do you have the if ( defined( 'WPSEO_VERSION' ) ) {} conditional? –  Chip Bennett Apr 9 '13 at 12:47
add comment

3 Answers

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' );
share|improve this answer
add comment

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

share|improve this answer
add comment
<?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.

share|improve this answer
    
Please add an explanation to your answer: why could that solve the problem? Where is the site name in your answer? –  toscho Apr 9 '13 at 12:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.