Head & Meta Hooks: The Silent Failures WordPress Won’t Warn You About
These five hooks control what WordPress writes into <title>, into <head>, into the <body> class list, and right before </body>. On paper, plumbing. In practice, this is exactly…

Filter Hook since 2.8.0
Filters the CSS classes on <body>
body_class lets CSS target context without extra wrappers. Return the array — do not echo class names.
When body_class() prints the body tag in the template.
apply_filters( 'body_class', string[] $classes, string[] $css_class );$classes string[] — Body class names.$css_class string[] — Additional classes passed to body_class().add_filter( 'body_class', function( $classes ) {
if ( is_user_logged_in() ) {
$classes[] = 'user-logged-in';
}
return $classes;
} );Add a logged-in class for CSS and JS hooks.
add_filter( 'body_class', function( $classes ) {
if ( is_singular( 'book' ) ) {
$classes[] = 'book-' . get_post_field( 'post_name' );
}
return $classes;
} );Add a slug-based class for per-book styling hooks.

These five hooks control what WordPress writes into <title>, into <head>, into the <body> class list, and right before </body>. On paper, plumbing. In practice, this is exactly…
Yes — search $classes with array_search() and unset() the key, then return the array.
Source: wp-includes/post-template.php
One session: this hook, then each related_hooks entry. Walk it and tell us what to change.
body_class → the_content
Practice the body_class WordPress filter hook in our interactive sandbox — a VS Code-style editor with a step-by-step body_class tutorial, add_filter exercises, and instant feedback. No local WordPress install required.