WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When viewing my blog in the browser, the body tag (on the index page) has the following class:

<body class="home">

On other pages (for this example, a page that pulls in posts that are within the category "project"), the body tag has even more classes:

<body class="archive category category-project category-3">

Both of these are rendered using the following code, contained within the html_header part:

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

I was wondering whether there was a way in which I could isolate the page descriptive class (1st example - home, 2nd example - category-project) that this command targets and use within the page.


share|improve this question
Your question is pretty hard to understand. Please reword and tell us your use case. – kaiser Feb 6 '13 at 10:09
Reworded. Thanks. – howardrocks Feb 6 '13 at 10:39
can you explain what your goal is? what you want to do exactly? – WP Themes Feb 6 '13 at 10:54
I want to use the page name to pull in page specific includes. For example, for a page that is exclusive to the category project I want to pull in an include called intro-category-project.php, which I would point the code in the direction of using <?php include('parts/shared/intro-' . $CLASS_THAT_THE_BODY_USES . '.php'); ?> – howardrocks Feb 6 '13 at 11:12
up vote 0 down vote accepted

The Function get_body_class() gives you an Array containing all the classes that are added to the body, so you can reuse them.

share|improve this answer

Your Answer


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.