Add your own title separator characters using Yoast SEO’s wpseo_separator_options filter

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


Comments

5 responses to “Add your own title separator characters using Yoast SEO’s wpseo_separator_options filter”

  1. You should specify the whole code to make this possible.

    1. James Revillini Avatar
      James Revillini

      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.

  2. Robert Glen Fogarty Avatar
    Robert Glen Fogarty

    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.

    1. James Revillini Avatar
      James Revillini

      You’re welcome, Robert. Thanks for taking the time to leave a note 🙂

  3. Sumesh chandra Avatar
    Sumesh chandra

    Thanks for the code, James. Really helped a lot and grateful to you.

Leave a Reply

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