WordPress Categories to the Body Class CSS Plugin

I needed to make CSS changes to a specific category on one of my WordPress sites, this plugin is the result. My WordPress side project started off as a simple review blog and then evolved into more than it was supposed to be. Because of this, I ended up with categories where I should have had custom post types. Rather than making the custom post types and converting the posts over I used this quick fix to make a certain category display much differently than the rest.

Download Plugin

To be fair and give credit where credit is due – the code came directly from this blog post by Philip Newcomer and I put it into a plugin rather than adding it to my theme’s functions.php file.

Here is Philip’s description of the code:

Here’s a little function that will add each of a post’s categories to the body class of the single post page (assuming your theme uses the body_class template tag)..

To see how to make plugins instead of editing your theme’s functions.php file check out this blog post by Brian Hogg.

WordPress SEO - Titles & Meta - Types 1 - JSnowCreations

Fix Yoast’s WordPress SEO Title & Meta Variables with Types Custom Fields

If you are like me you insist on using Yoast’s WordPress SEO plugin to control you WordPress website or blog’s page titles and meta tag data via the “Titles & Meta” settings page found in the WordPress SEO. If you’re really like me then you are also too lazy to custom PHP code your WordPress theme to have custom post types, custom taxonomies, and/or custom fields so you instead use a plugin to quickly and easily make all the custom post types/taxonomies/fields for you, such as the “Types” WordPress plugin!

Yoast’s WordPress SEO plugin is a breeze to use even for beginners, and the Types plugin is also fairly easy to use for moderately experienced WordPress users. However, getting custom post types, custom taxonomies, and custom fields to work with the “Titles & Meta” variables within WordPress SEO’s settings can be tricky.

Allow me to clear up the minor issue I ran into with WordPress SEO’s Titles & Meta variables and Types custom fields.

If you look here or one of the many other WordPress SEO guides you will find many options to use on the Titles & Meta variables, but the three we are focusing on in this post are:

These three variables are used to input values from custom fields, taxonomies, and taxonomy descriptions into WordPress SEO Titles & Meta fields which then control SEO Meta Tags.

Custom taxonomies and taxonomy descriptions work just as you would think – replace “custom-tax-name” AND the surrounding “<” “>” brackets in the %%ct_…%% and %%ct_desc_…%% variables with your custom taxonomy slug.


After using these variables correctly, your WordPress SEO Titles & Meta fields should correctly input custom taxonomy names and taxonomy descriptions into your site’s SEO meta tags!

However, the custom fields variable has a small issue with the Types plugin that might cause trouble for some.. It’s not even really an “issue”, just something many will overlook. Make sure to read below before you go searching “%%cf_%% not working with Types custom field” at Google!

The problem with WordPress SEO’s Titles & Meta variables and Types custom fields, and how to fix it!

WordPress SEO - Titles & Meta 1 - JSnowCreations
WordPress SEO – Titles & Meta 1 – JSnowCreations

Given how simple it is to get custom taxonomies and taxonomy descriptions made with the Types plugin working with Yoasts’s WordPress SEO Titles & Meta, you’d think getting custom fields from Types to work would be as simple as plugging the custom field’s slug into the %%cf_…%% variable such as %%cf_download-developer%%, right?

Wrong! The Types plugin, along with many other custom-field-creating plugins, adds a prefix to the beginning of custom field slugs and Types’ custom field slug happens to be “wpcf-“. So, in order to get custom fields created with the Types plugin to work with WordPress SEO’s Titles & Meta variables you must simply add the wpcf- prefix from Types to your Titles & Meta variables.


After adding the extra prefix from Types to your custom field slugs entered in the Titles & Meta variables in WordPress SEO’s settings, your SEO meta tags should start correctly outputting custom field values! 😀

WordPress SEO - Titles & Meta - Types 1 - JSnowCreations
WordPress SEO – Titles & Meta – Types 1 – JSnowCreations

Yoast’s WordPress SEO’s Titles & Meta variables work great with custom fields made with the Types Plugin once you know what your doing!

I suppose it also helps if you find my post regarding the issue rather than blindly trying and getting things 99% correct like the guy here who just left in the “<" ">” brackets from WordPress SEO’s guide on Titles & Meta variables. Too bad the PAID support he got didn’t give him the easy, and correct, solution of just removing the brackets! 😮

Please, comment below with any questions of comments you may have about this post, or anything else regarding Yoast’s WordPress SEO plugin or Types!