Custom Body Class

Unless otherwise indicated, the code snippets you see below should be placed into your theme's functions.php file.

Add body class to all pages on your site:

Add body class to a page with a slug of ‘sample-page':

Add body class to a page with an ID of 1:

Add body class to a category page with a slug of ‘sample-category':

Add body class to a category page with an ID of 1:

Add body class to a tag page with a slug of ‘sample-tag':

Add body class to a tag page with an ID of 1: