Remove the Site Name From Post Titles
Shows only the post or page name in the browser tab and search results on single posts and pages, leaving more room for a descriptive title.
Opens WPIDE on
Code
// Post types without the site name in the title (empty array = all).
$wpide_title_post_types = array();
add_filter( 'document_title_parts', function ( $parts ) use ( $wpide_title_post_types ) {
if ( ! is_singular() || is_front_page() ) {
return $parts;
}
if ( $wpide_title_post_types && ! is_singular( $wpide_title_post_types ) ) {
return $parts;
}
unset( $parts['site'], $parts['tagline'] );
return $parts;
} );
Notes
Set $wpide_title_post_types to limit it to certain post types.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.