body_class WordPress Filter Hook
The body_class hook is one of the most important hooks in WordPress. It allows themes and plugins to add classes to the body element of the page. This can be used to style specific pages or elements differently. It is also used by some plugins to add specific classes to the body so that they can target those elements with JavaScript or CSS.
apply_filters( 'body_class', string[] $classes , string[] $class ) #
Filters the list of CSS body class names for the current post or page.
Parameters
- $classes
(string[])An array of body class names.
- $class
(string[])An array of additional class names added to the body.
More Information
Note that the filter function must return the array of classes after it is finished processing, or all of the classes will be cleared and could seriously impact the visual state of a user’s site.
Source
Changelog
Version | Description |
---|---|
2.8.0 | Introduced. |