Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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(); ?>">
share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

directly in the body tag line:

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

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

share|improve this answer
add comment

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;
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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