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:

  1. Install Advanced Custom Fields plugin (free or pro version).
  2. Install Websentia Add Body Class with ACF plugin.
  3. In ACF settings, create a field group (name as you wish).
  4. In your new field group, add a “text” field with the label “body_class” (no quotes).
  5. 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.
  6. 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.