How to Change The Separator in The Title of WordPress Website
Title HTML tag in WordPress or on a Web Pages, defines the Title of the document and is used on Search Engine Result Pages (SERPs) to display the Preview Snippets for that particular page. Title tags are very important for SEO as well as social sharing.
Why Title Tags are Important for SEO
Optimizing title tags for your WordPress site must be your number 1 priority and best practices includes using right keyword in the beginning of page title for higher ranking in SERPs. Along with keywords, title tag separators are also important part of the page title.
Title tag is the main text that briefly describes the content on the page and helps search engines to rank an article into SERPs. That’s why title tags have been considered one of the most important on-page SEO elements.
So in this article we will be focusing on how to change the separator in the title tag in WordPress.
Change The Separator in The Title Tag
WordPress by default use pipes “|” as separator in the title tag but we can change it to something of our choice very easily. Official documentation on codex for wp_title() suggests the following way to change the title tag separators. Here the first parameter is separator for the page title and we can change it to dashes, commas or anything else of our choice.
<title><?php wp_title( '|', true, 'right' ); ?></title>
This is the easiest way to change the title tag separators but it does not always work since many plugins modify WordPress title function to generate the page titles.
So the best way to change the separator in the title tag is to use wp_title filter for modifying the output of the WordPress title function. You can page this following code snippet in your WordPress theme’s functions.php ( Dashboard > Appearance > Editor > function.php ) file.
* Customizing the Title Separator from the whole website.
* Put this code Last of the function.php file.
// change the title tag separators in WordPress
function asksatya_change_wp_title_separator( $title, $sep )
// Set new separator
$sep = '›';
// Set new title with separator
$title = str_replace( '|', $sep, $title ); return $title;
add_filter( 'wp_title', 'asksatya_change_wp_title_separator', 10, 2 );
Upon adding the above code snippet, it will change the default page title separator “|” (pipes) with “ ›” (dashes).