Add a custom class name to Wordpress body tag?

Posted by Scott B on Stack Overflow See other posts from Stack Overflow or by Scott B
Published on 2010-03-17T21:32:47Z Indexed on 2010/03/17 21:51 UTC
Read the original article Hit count: 147

Filed under:
|

I'd like to place a directive in my theme's functions.php file which appends a classname to the wordpress body tag. Is there a built-in API method for this?

For example, my body tag code is...

<body <?php if(function_exists("body_class") && !is_404()){body_class();} else echo 'class="page default"'?>>

And it results in the following being written to the body tag (depending on the context in which the page is presented (page, post, logged-in, etc)

<body class="home blog logged-in"> 

Depending on the child theme I'm using at the time, I want it to be...

<body class="home blog logged-in mychildthemename"> 

© Stack Overflow or respective owner

Related posts about php

Related posts about Wordpress