How to remove blog title from post titles


Hi, for a post how to remove the Blog title part from ... title tags.

Eg:

<title>Lenovo Mobile Service Center in Yavatmal – Mobile Service Center</title>

How to just remove this part from title tags "– Mobile Service Center"


Hi Venkatesh,

The document title is handled on WordPress core in the wp_get_document_title() (see documentation here) since WordPress version 4.4. So to remove your site title as you requested, you could use WordPress core document_title_parts. Here is an example snippet you may add to your child theme functions.php:

add_filter( 'document_title_parts', 'example_wp_title' );

function example_wp_title( $parts ) {

  // Remove the site name from the document title.
  unset( $parts['site'] );

  return $parts;

}

Happy coding,


Thanks alot Thierry Muller. Perfect πŸ™‚

Write a reply

Login or register to write a reply, it's free!