This article was originally published on December 3, 2018.
The Yoast SEO plugin allows you to define a template for your SEO titles and meta descriptions for all of your post types. By default, WordPress has a few post types: Posts, Pages, Attachments, Revisions, Navigation Menus, Custom CSS, and Changesets. The two default post types that you will work with are Posts and Pages.
WordPress posts and pages are both post types. This may be a little confusing to you, so for the sake of avoiding confusion, I’m going to use the term
content type instead. Going back to the topic at hand, some themes and plugins may use additional content types. For example, the Divi WordPress theme* uses a Project content type and the WooCommerce plugin uses a Products content type. You can even create your own content types by adding code in your functions.php file or by using a plugin such as the Custom Post Types UI plugin.
Having different content types can make your site more organized and easier to perform SEO work on because you can specify a different template for each content type. If your website has 100 pages, imagine having to optimize each page’s SEO title and meta description manually. In this case, if you can think of a common structure for each of your content types’ SEO titles and meta descriptions, then you can leverage your work by defining a template that uses Yoast’s snippet variables. For example, let’s say I created the following pages with a custom content type named Services, and I used the following as the page title:
- Custom Web Design
- WordPress Development
- Digital Marketing
If I wanted my SEO titles to follow a certain format like so:
- Quality Custom Web Design Services in Atlanta
- Quality WordPress Development Services in Atlanta
- Quality Digital Marketing Services in Atlanta
Then this is what I would use in the Yoast SEO title section:
Quality %%title%% Services in Atlanta
You would follow the same principles when creating the meta description template.
%%sitename%% is located in Atlanta, GA and offers awesome %%title%% Services to small businesses nearby. Blah, blah, blah.
If Mr. Technique were the site name, this meta description template would generate the following meta descriptions:
- Mr. Technique is located in Atlanta, GA and offers awesome Web Design Services to small businesses nearby. Blah, blah, blah.
- Mr. Technique is located in Atlanta, GA and offers awesome Quality WordPress Development Services to small businesses nearby. Blah, blah, blah.
- Mr. Technique is located in Atlanta, GA and offers awesome Digital Marketing Services to small businesses nearby. Blah, blah, blah.
If you needed to manually create a specific page’s SEO title and meta description that you didn’t want to be like all of the rest, then you could still manually define them in the Yoast SEO section of that specific page in the admin area.
If all of our services were created using the page content type and there was no service content type, then defining the SEO title template for pages wouldn’t make sense on every page because non-service pages like our contact page would have SEO meta tags that would look like this:
SEO Page Title: Quality Contact Us Services in Atlanta
Meta Description: Mr. Technique is located in Atlanta, GA and offers awesome Contact Us to small businesses nearby. Blah, blah, blah.
How to Set Up SEO Title Templates for Custom Post Types and Custom Fields
In this version of mrtechnique.com, I have a Project custom post type which uses custom fields that I created with the Advanced Custom Fields (ACF) plugin. The custom fields that I created were grouped together. If you wanted to access the custom field values in a group using Yoast, your Yoast snippet variables would need to follow this format:
The cf part of the variable stands for custom field. After the cf, you would insert the field group name (if you have one) followed by the field name. If your variables aren’t in a field group, your Yoast snippet variables would follow this format:
If you’re using ACF to define your custom fields, you can find the name of the field group and/or name of the field in the Field Name section.
Currently, a link to every one of our individual Project post type pages are shown in our website portfolio page, and each one of those pages follow this format:
%%field_group_name_type_of_business%% Responsive Web Design Project %%sep%% %%field_group_name_city%% %%field_group_name_state%%
This ends up producing SEO titles like this for all Project post type pages:
- Dentistry Responsive Web Design Project • Conyers, GA
- Massage Spa Responsive Web Design Project • Atlanta, GA
- Job Surveillance Responsive Web Design Project • Brooks, GA
Below is a screenshot of one of our individual project page’s values that are referenced.
You may wonder how I got “Georgia” to turn in to “GA” in the SEO title. Well, I made the State field a Select field and made the state values different than the labels like so:
DC : District of Colombia
FL : Florida
GA : Georgia
You can find the full list of states here.
How to Set Up SEO Title Templates for Divi’s Custom Post Type
As mentioned earlier in this blog post, the Divi WordPress theme* has its own custom content type called Project. Our website previously used the Divi theme, so I’m pretty familiar with it. Going back to the subject at hand, this content type has two taxonomies that you could use with Yoast: Categories and Tags. Divi’s Project categories and tags are custom taxonomies, so using %%category%% and %%tag%% will not show the projects’ categories and tags in your SEO title and meta description.
The names to use for Divi’s Project category and tag taxonomies are project_category and project_tag respectively. You can find these names by going to Projects -> Categories and Projects -> Tags in the WordPress admin area. If you look at the url in address bar, the end of the urls will look like these:
To show your projects’ categories and tags, you need to use %%ct_project_category%% and %%ct_project_tag%%. The ct part of the variable stands for custom taxonomy. Learn more about using template variables for custom content type fields and taxonomies. Let’s use this Project content type SEO title template for an example:
%%ct_project_tag%% %%ct_project_category%% Project %%sep%% %%title%%
Let’s say you used an industry or type of company for all of your projects’ tags, and you used a service for your projects’ categories. If you did, then you could generate default SEO titles like this:
- Law Firm Web Design, SEO Project • The Dickerson Firm
- Videographer Web Design Project • Helena Films
- Massage Spa Web Design, SEO Project • Treat Your Feet
Here’s what the SEO title looks like on one of our project pages when it was using the Divi theme:
If you had hundreds of projects, this could save you a ton of time. You could use city names for your projects’ categories or tags if you wanted to optimize each project for one or more areas. If you define more than one category or tag, they would all show up in the title or meta description as well.
Where to Define Templates for the SEO Title and Meta Description in the Yoast Plugin
Templates for SEO titles and meta descriptions can be done in both the free and premium version of the Yoast SEO plugin. Editing the templates can be done in the Yoast SEO -> Search Appearance -> Content Types section or you can access the section directly by going to www.yourwebsite.com/wp-admin/admin.php?page=wpseo_titles#top#post-types. Any custom content types will be added automatically to this section:
Be sure to replace yourwebsite.com with your own website URL. You would edit the templates in this section. To edit the templates for the archive pages, you would go to the Taxonomies tab or go to www.yourwebsite.com/wp-admin/admin.php?page=wpseo_titles#top#taxonomies.
Thanks for reading this post. If you found this post informative, please feel free to share or comment below.