Change character appended in tab title?

This should be easy: a “-” character is appended between the parts of our tab titles (site title - tagline on home page, and page title - site title on other pages). Can we change this to a “|” character?

I see in other threads you suggest installing Yoast SEO to gain better control of tab titles. We are happy with the titles themselves and the way they are appended, we simply want to change the appending character. Is that possible?

Thanks!

Hello Ergo,

Thanks for writing in!

By default, the title separator is already using “|” unless otherwise there is a 3rd party plugin or a custom php code that changed it. You can make use this php code in your child theme’s functions.php file to override it:

if ( ! function_exists( 'x_title_separator' ) ) :
  function x_title_separator( $sep ) {

    $sep = "|";

    return $sep;

  }

  add_filter( 'document_title_separator', 'x_title_separator' );
endif;

We would love to know if this has worked for you. Thank you.

Funny you should mention that, because I think our site used to have the | and that is perhaps where I got the idea, as we then added it to our titles and tagline but were surprised to recently find the - separating them.

Anyhow, I tried to use your code but we don’t have a child theme so I stuck it in the global JS but it didn’t work. Probably just a JS error on my part because I don’t know it. I also tried wrapping your code in a function but that didn’t work either.

You can see on our home page and a typical content page that the --s are still there. I left your code in the global JS for now since it doesn’t seem to be hurting anything.

Incidentally we just upgraded Wordpress and all our plugins, but I am not sure when the dashes started.

Thanks for your help!

Steve

Hello Steve,

We have checked our testing servers and it is using “|” by default. Would you mind providing us access to your site so that we can check your settings? Please create a secure note with the following info:
– Link to your site
– WordPress Admin username / password

To know how to create a secure note, please check this out: https://theme.co/apex/forum/t/how-to-get-support/288

Thanks.

Hi Steve,

Thank you for the credentials, but your site has no child theme on it, so I was not able to test. Please set up a child theme and activate it then add the code provided by Ruenel on the Child theme’s functions.php file. That’s a php code so you cant put that on the Theme Options > JS area.

Access your site files via FTP (or cPanel file manager) and navigate to /wp-content/themes/x-child/ on that directory you can see the functions.php file, open/edit that file and add the code provided by Ruenel above. Make sure it’s your child theme is the one active on the Appearance > Themes.

Let us know how it goes,
Cheers!

Hi Friech,

I think I successfully added the child theme and edited the php. It seems to have fixed the problem!

Thanks for your help! You guys are the best!

Steve

You are most welcome. :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.