Add Custom Class to Body

Adds a custom class to the body tag

PHP

function add_custom_body_class($classes) {
    $classes[] = 'my-custom-class';
    return $classes;
}
add_filter('body_class', 'add_custom_body_class');

Snippet Feedback

Did this snippet work for you? Do you have any questions about this snippet? Leave some feedback below.
SHARED BY

Language

Did it work?

Save Snippet

Embed Snippet

To embed this snippet on your site, copy this html code and paste into your webpage. Learn more
By embedding snippets on your site, you are agreeing to our terms and conditions.

Embed Snippet

To embed this snippet on your site, copy this html code and paste into your webpage. Learn more
By embedding snippets on your site, you are agreeing to our terms and conditions.

Embed Snippet

To embed this snippet on your site, copy this html code and paste into your webpage. Learn more
By embedding snippets on your site, you are agreeing to our terms and conditions.