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.

Does anyone know where I can get a list of all the body classes generated by body_class() for every sections and every conditions, including custom post-types, etc.?

For example, for a search result page with certain conditions (eg. logged-in), the function produces this:

<body class="search search-results logged-in admin-bar single-author two-column right-sidebar">

I need the full list for reference in creating a theme.

Cheers!

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Several classes have been added since WordPress 2.8 (when the WPEngineer post was written). I would refer directly to the body_class() Codex entry, which currently lists the following:

  • rtl
  • home
  • blog
  • archive
  • date
  • search
  • paged
  • attachment
  • error404
  • single postid-(id)
  • page-id-(page_id)
  • attachmentid-(id)
  • attachment-(mime-type)
  • author
  • author-(user_nicename)
  • category
  • category-(slug)
  • tag
  • tag-(slug)
  • page-parent
  • page-child parent-pageid-(id)
  • page-template page-template-(template file name)
  • search-results
  • search-no-results
  • logged-in
  • paged-(page number)
  • single-paged-(page number)
  • page-paged-(page number)
  • category-paged-(page number)
  • tag-paged-(page number)
  • date-paged-(page number)
  • author-paged-(page number)
  • search-paged-(page number)
  • tax-(taxonomy name) (since 3.1)
  • term-(term name) (since 3.1)
  • admin-bar (since 3.1)
share|improve this answer
    
(Also @Hiranthi) Cheers! But do you know if body_class() also generates specific classes for custom post-types as well? –  gmaggio Jul 19 '11 at 0:43
1  
It appears that it does not; however, if you're using a custom single-{posttype}.php template file, then you get a single-{posttype} class. –  Chip Bennett Jul 19 '11 at 2:57
    
Plugins can of course hook into body_class and add an unlimited number of extra classes, so this list can only contain the classes added by WP core code. –  Jan Fabry Jul 19 '11 at 13:33
2  
The Codex entry (and thus this list) should be updated, I see that post formats and post type archives also generate body classes. Someone should check the source and add the missing classes. –  Jan Fabry Jul 19 '11 at 13:36

There's a list of that on WPEngineer.com

share|improve this answer

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.