Body Class Filter

Example 1 — Basic

Adds a new class to all pages.

Example 2 — With a Conditional

Adds a new class to all single post pages.

Example 3 — On Sub Pages Only

Adds a new class to all sub pages (i.e., those with a parent).

Example 4 — Based on Layout

Adds a new class if the default Site Layout is 3 columns.

Example 5 — Primary Post Category

Adds a new class named after the primary category to single post pages.

Example 6 — All Post Categories

Add classes for all assigned categories to single post pages.

Example 7 — WordPress Body Classes

Add the default WordPress body classes to all pages.

Example 8 — Based on Page Template

Adds a new class to pages where the No Sidebars Template is enabled.

Example 9 — Post Author

Adds a new class to single posts and author archives which includes the author’s ID.

Reference