How to Add Custom Body Class

Code snippets should be placed in your child theme's functions.php file. Note: Do not to copy the opening php tag in each snippet.

Below is the code to add body class to all pages on your site:

Below is the code to add body class to a page with a slug of ‘sample’

Below is the code to add body class to a page with an ID of 1

Below is the code to add body class to a category page with a slug of ‘custom-category’

Below is the code to add body class to a category page with an ID of 1

Below is the code to add body class to a tag page with a slug of ‘custom-tag’

Below is the code to add body class to a tag page with an ID of 1