• I use some custom post type and tried to use this to create a seo friendly title. I added this in function.php of my theme but does not works. anybody please tell my what’s wrong here.

    add_filter( 'wp_title', 'bd_wp_title', 10, 2 );
    function 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';
    	}
    	return $title;
    	if (is_singular( 'albums' )) {
    		$title = ''. get_the_title() .' Bangla Mp3 '. strip_tags(get_the_term_list( get_the_ID(), 'genre', '', ' ', '' )) .' Free download';
    	}
    	return $title;
    }

Viewing 1 replies (of 1 total)
  • Try deleting the first return $title;.

    I’m also pretty sure that the template tags you’re using are not working that early in the page load since the loop has not run yet. Try passing get_queried_object_id() to get_the_title() and replace get_the_ID() with get_queried_object_id().

Viewing 1 replies (of 1 total)
  • The topic ‘Filtering wp title not working’ is closed to new replies.