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.


  • Your question is pretty hard to understand. Please reword and tell us your use case.
    – kaiser
    Feb 6, 2013 at 10:09
  • 1
    can you explain what your goal is? what you want to do exactly?
    – WP Themes
    Feb 6, 2013 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'); ?> Feb 6, 2013 at 11:12

1 Answer 1


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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