I'm working on my WordPress testing website and I'm trying to change the title tag to the very short hyphen. (-) I've added a code into the functions.php file that allows me to change the title tag.

add_filter ('document_title_separator', 'wpse_set_document_title_separator') ;

wpse_set_document_title_separator ($sep)
    return ('-') ;

So at the part in the code, ('-') is where I've placed my desired title tag the SHORT hyphen but instead it remains as the default (—) LONG hyphen... Help me pls.

  • Did you try setting up a higher priority for your add_filter? Something like: add_filter ('document_title_separator', 'wpse_set_document_title_separator', 999) ; Sep 3, 2017 at 5:15
  • Didn't work... :(
    – grey221
    Sep 3, 2017 at 6:02
  • If you look at the filter in source, you can see why this happens. After the filter is applied, the wptexturize function on line 1067 converts short hyphens to long hyphens.
    – Milo
    Sep 6, 2017 at 3:35

1 Answer 1


The return function doesn't require (). So you'd want your function to look like this:

function wpse_set_document_title_separator ( $sep) {
    return '-';
add_filter( 'document_title_separator', 'wpse_set_document_title_separator' );
  • I mean I can change the title separator to anything else like | for example and it works. I just cannot get the short hyphen.
    – grey221
    Sep 3, 2017 at 2:10
  • Try return '‐';
    – Cedon
    Sep 3, 2017 at 2:17
  • Alright, that literally just made the title tag ‐.
    – grey221
    Sep 3, 2017 at 2:29
  • I forgot to ask, are you running an plugin like Yoast SEO? I just tried the above code and it was working fine as I originally typed it. Also, it appears that WordPress defaults to - as the separator so something else like a plugin might be overriding.
    – Cedon
    Sep 3, 2017 at 10:00
  • Hey there I solved it, I just went through a list of hyphen symbols until I found the right one. Thanks for the help nonetheless.
    – grey221
    Sep 3, 2017 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.