Change title slug or separator in WordPress

I have added add_theme_support( 'title-tag' ); function in theme setup in my functions.php now it shows the title as:

title-WordPress

I would like it to be changed as follows:

title | WordPress

Read more here: Change title slug or separator in WordPress

1 thought on “Change title slug or separator in WordPress

  1. This worked for me

    add_filter(‘document_title_separator’, ‘doc_title_separator’, 10);
    function doc_title_separator($sep){
    if( is_singular( ‘post’ ) ){
    $sep = ‘|’;
    }

    return $sep;
    }

Leave a Reply

Your email address will not be published. Required fields are marked *