The WPFolks app is out on iPhone and Android. Free, no ads. Download on the App Store Get it on Google Play
Skip to main content
Login Join
Snippet · PHP

Add Custom Body Class

Shared by Amit Dholiya · July 13, 2026

1 copy
32 views
1 upvote
Back to Snippets

Add your own CSS class to every page.

Steps

  1. Open functions.php.
  2. Add the code below.
  3. Save the file.

Done — a custom class will be added to the <body> tag.

function add_custom_body_class($classes) {
    $classes[] = 'custom-site';
    return $classes;
}
add_filter('body_class', 'add_custom_body_class');
Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments

Proudly supported by