I have created a Wordpress site and titles were working just fine. Then, some time and plugins installed later, I noticed that in SOME pages I get the title repeated 2 times.

Example of wrong page title: Contact - NAME | NAME

Example of normal title: Our Services | NAME

Now, if I go to General Settings and change title it will change both, no improvement. SEO by Yoast has the option to reset page titles, but that just removes all titles leaving the current URL as page title, so no good either.

Here is the code I originally had: <title><?php wp_title(''); ?><?php if(wp_title('', false)) { echo ' | '; } ?><?php bloginfo('name'); ?></title>

Here is the code I am using now: <title><?php wp_title('|'); ?></title>

To sum up, I think somewhere in the database there's a wp_title repeated: once using '-' as separator, another one (the current one) using '|'.

Any help will be most appreciated, thanks!

  • Just a note: Don't use uppercase or bold letters until there's a real reason. So far it looks like SCREAMING! and we want to avoid that, ok? Please edit your question. THanks.
    – kaiser
    Commented Nov 13, 2012 at 15:54
  • 1
    Done it. I meant it for clarification, but apparently failed. Thanks anyway
    – cmykrgbb
    Commented Nov 13, 2012 at 15:58

2 Answers 2


In order to play nicely with Plugins or other code that attempts to modify the HTML document title content (i.e. wp_title() output), you should always and only output this:

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

...and if you want to modify that output yourself, filter wp_title instead of hard-coding anything inside the <title></title> tags.

So for your example code:

<title><?php wp_title(''); ?><?php if(wp_title('', false)) { echo ' | '; } ?><?php bloginfo('name'); ?></title>

Replace all that with:

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

...and then add a callback to the wp_title filter:

function wpse72446_filter_wp_title( $title ) {
    if ( '' == $title ) {
        return get_bloginfo( 'name' );
    return $title;
add_filter( 'wp_title', 'wpse72446_filter_wp_title' );

That way, your modifications will play nicely with any Plugin _doing_it_right() (like Yoast SEO).


Yoast has some great documentation on setting up page titles with his plugin. Even clear notes on how to call wp_title().

His exact instructions are to use wp_title( '' );

Then you simple use the options panel to setup the rules for title rewrites.

  • Yeah, I've seen it, but it doesn't solve the problem. Anyway, mine is the same except I use a '|' separator and the code I am using comes from Wordpress codex so should be good.
    – cmykrgbb
    Commented Nov 13, 2012 at 16:18
  • Yoast's code inserts the separator, so no need for you to do it in your code. I know it works as Josh has it documented, I have it installed and configured on a number of sites. So unless there's something you're not telling us in your question this is the obvious answer.
    – Steve
    Commented Nov 13, 2012 at 16:20
  • I just de-activated Yoast's plugin and it's working fine again, so that explains it. Cheers!
    – cmykrgbb
    Commented Nov 13, 2012 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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