Archived topic
Title tag separator
3 replies · Started by Tara on September 6, 2015
Hi Tom
What's the best way to change the separator in the <title> tag?
I've found https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_title but it's still not clear where to customise the separator, or how this function differs from the default titles.
All I really need is to change a single character from '|' to '-'.
Thanks
Tara
Hi Tara. Try adding this to a child theme functions.php file:
add_filter( 'wp_title', 'my_wp_title' );
function my_wp_title($title) {
$title = str_replace( "|","-",$title );
return $title;
}
Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/
That's perfect, thank you!
You're welcome; glad to help.
