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).