Add Body Class with ACF
You can use Advanced Custom Fields (free or pro version) and this plugin to add custom body classes to your WordPress pages, posts, and other custom post types.
Here’s how this works:
- Install Advanced Custom Fields plugin (free or pro version).
- Install Websentia Add Body Class with ACF plugin.
- In ACF settings, create a field group (name as you wish).
- In your new field group, add a “text” field with the label “body_class” (no quotes).
- For ACF display options, choose where you want this to display such as pages or (not “and”) posts, or any custom post type of your choice. You can also limit who accesses based on ACF’s functionalities.
- Open a page, post, etc or create a new one. You’ll see a custom field where you can add body classes (separated by spaces such as favorites allowed gardening and so forth). These classes will be added to the body tag for that page/post only.