Add a Different CSS Body Class to a Page in WordPress

Using WordPress filter ‘body_class‘ you can add a unique CSS class to the body element of a page by passing in what pages you want the new CSS class applied to.

So in the above code I want an additional class ‘beaverbuilder’ applied just to the page with the ID of 8. This code will add the extra CSS class to the other default classes just for that page and return the default classes for all the other posts and pages.

To target other posts/pages/archives etc set your desired conditionals.