0

My theme already has a specific body class filter for the colorscheme it uses. How can I also add a body class filter for the page name? Basically I want to combine these statements:

<body <?php body_class(); ?>>
<body class="<?php echo get_stencil(); ?>">

I've been trying but I just keep getting error messages with variations like this:

 <body class="<?php echo get_stencil(); ?> <?php body_class(); ?>">
1

directly in the body tag line:

<body <?php body_class( get_stencil() ); ?>>

http://codex.wordpress.org/Function_Reference/body_class#Adding_More_Classes

1

Add following filter code in functions.php to add any custom class to body.

// Add specific CSS class by filter
add_filter('body_class','my_class_names');
function my_class_names($classes) {
// add 'class-name' to the $classes array
$classes[] = 'class-name';
// return the $classes array
return $classes;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.