Despite Yoast’s discouragement of using the wpseo_separator_options
filter to add more separator options to the configuration page (SEO > Search Appearance), I really wanted to give it a shot so my URLs would have a neat separator that’s not commonly seen.
Hookr.io had a great breakdown of how wpseo_separator_options can be implemented. I added the PHP to a code snippet using the awesome Code Snippets Wordpress Plugin but my initial attempts had no effect on the list of available separator characters.
I finally figured out that you don’t need to alter the $separators
array and return it … you just return your own array of additional separators and they will be appended. Here’s the code:
add_filter('wpseo_separator_options', function ( $separators ) { return ['γ', 'ί·', 'β¦', 'β', 'β―']; }, 10, 1);
Note: Yoast specifically recommends against using a separator other than what is provided in the plugin because some search engines (Google included) will strip them from the search results page.
I am going to take my chances and check my search results in a week or so.
UPDATE: I can confirm that Google doesn’t strip the γ character out as of 2021-09-10
You should specify the whole code to make this possible.
I did give the code. Just pop it into a snippet using the plugin I referenced, save the snippet, and activate. You’re good to go.
Thanks for the writeup, James! This was extremely helpful. I just wanted the plain ol’ | separator to which my eyeballs had grown accustomed, and now it’s back! Very grateful to you.
You’re welcome, Robert. Thanks for taking the time to leave a note π
Thanks for the code, James. Really helped a lot and grateful to you.