apply_filters( 'body_class', string[] $classes , string[] $css_class )
Filters the list of CSS body class names for the current post or page.
Parameters
-
$classes
string[] -
An array of body class names.
-
$css_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
File: wp-includes/post-template.php
.
View all references
$classes = apply_filters( 'body_class', $classes, $css_class );
Changelog
Version | Description |
---|---|
2.8.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
Add New Classes
You can add additional body classes by filtering the {@see ‘body_class’} hook.
To add the following to the WordPress Theme functions.php file, changing my_class_names and class-name to meet your needs:
Following function adds CSS classes that may be useful
Remove Classes
Remove an existing body class by un-setting the key from the
$classes
array.