Was recently working on a new post layout for a site that we’re wanting to do some A/B testing for before shipping out the feature for the entire backlog of posts.
Once we implement, there may be a few posts that keep the old layout which we’ll be controlling by giving those posts a certain body class within the WordPress dashboard when editing those posts. However, there are some functions that are used on the page that we’d like to control based on the layout (ex. a related post function calling 3 posts rather than 4).
To do this, here is a quick conditional that you can add to your
functions.php file or a general use plugin that will allow you to check whether or not a class exists in the body class for the page.