Change Separator Used in WordPress Title Tags

May 21, 2013 PHP, Plugins, WordPress

Change Separator Used in WordPress Title Tags

In the SEO Yoast plugin for WordPress, you can change the format of your title tags to have consistency across your site as well as strong SEO value. You can edit by post type, page, taxonomy, archive type and even a 404 error.

To change the separator symbol, defined in SEO Yoast by the %%sep%% tag, you’ll need to modify your theme’s header.php file. In between the <title> tags, add the wp_title WordPress function with your separator symbol in place of the pipe below.

<title><?php wp_title('|', true); ?></title>

PHP

The default for WordPress is the dash, but I prefer to use the pipe character. As you can see, the title tag for this post is Change Separator Used in WordPress Title Tags | Sliced in America with the new separator in place.

The true part of the function means to print out the result of the function (our final title tag) and not to send it to PHP. If we really wanted to, we could set it to false and store the result in a variable to make even more modifications, such as capitalizing every character using the strtoupper PHP function.

<title><?php
     $title_tag = wp_title('|', false);
     echo strtoupper($title_tag);
     ?>
</title>

PHP

The definitive tutorial on Yoast SEO can be found on the official site.

Update

Yoast SEO now includes an area to change the title separator without going through code.

Let's Talk About Your New Website

View Portfolio Contact Today