[Resolved] Title tag separator

Home Forums Support Title tag separator

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #134754
    Tara

    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

    #134774
    bdbrown

    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/

    #134815
    Tara

    That’s perfect, thank you!

    #134834
    bdbrown

    You’re welcome; glad to help.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.