Double Wp_title, Removing Title from theme doesnt solve the issue
-
I made a similar thread earlier. But in this thread I will try to explain as much as possible.
I use a custom theme based on underscores.
In it’s function.php there are a function,
add_theme_support( 'title-tag' );
So as far as I understand from reading some SOF answer, if this exist, I don’t have to add below function to header.php anymore to show title of pages.
<title><?php wp_title( '|', true, 'right' ); ?></title>
I removed it and my site is giving natural output as there arewp_head()
included.
<title> Title – Sitename </title>
Now, my site have 4 post type so using a SEO plugin is not enough. So I tryed to filter wp title for different post tipe. I added bellow filter to my function.phpfunction bd_wp_title( $title, $sep ) { global $paged, $page; if (is_singular( 'videos' )) { $title = ''. get_the_title() .' '. strip_tags(get_the_term_list( get_the_ID(), 'video-categories', '', ' ', '' )) .' Download HD Mp4, 3GP Mobile'; } if (is_singular( 'albums' )) { $title = ''. get_the_title() .' Mp3 '. strip_tags(get_the_term_list( get_the_ID(), 'genre', '', ' ', '' )) .' Free download'; } return $title; } add_filter( 'wp_title', 'bd_wp_title', 10, 2 );
But It doesn’t works. It only works properly if I add
<title><?php wp_title( '|', true, 'right' ); ?></title>
into my header.php. But then, my site return two <title> tag. One within wp_title() (1) and another is the one I add in header.php (2).
And those two title is different too. (2) gives me proper output likeTitle Mp3 genre free download
and (1) output default one
Title – Sitename
.
So, Why my filtering is not working for (1)? Am I missing something?
- The topic ‘Double Wp_title, Removing Title from theme doesnt solve the issue’ is closed to new replies.