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!

link|improve this question

57% accept rate
feedback

2 Answers

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)
link|improve this answer
(Also @Hiranthi) Cheers! But do you know if body_class() also generates specific classes for custom post-types as well? – Giraldi Maggio 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
1  
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
feedback

There's a list of that on WPEngineer.com

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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