February 9, 2009
In 2.7 WordPress added threaded comments with a neat little function that would output the comment code complete with loads of standard CSS classes, we also have post_class which outputs standard classes for post. In 2.8 the class-fest goes further with a new function: body_class.
Body class goes in the body tag of each web page and outputs classes depending on the type of page that is being viewed. At the moment it outputs the following classes (it should be obvious what each is for)
- rtl
- home
- blog
- archive
- date
- date-paged-#
- search
- search-paged-#
- paged
- paged-#
- attachment
- error404
- single
- single-paged-#
- page-paged-#
- postid-#
- attachmentid-#
- attachment-{mime type}
- (if date archive) date-paged-#
- (if author archive) author
- (if author archive) author-paged-#
- (if author archive) author-{name}
- (if category archive) category
- (if category archive) category-paged-#
- (if category archive) category-{slug}
- (if tag archive) tag
- (if tag archive) tag-paged-#
- (if tag archive) tag-{slug}
- page-parent
- page-child
- parent-pageid-#
- page-template
- page-template-{name}
- search-results
- search-no-results
- logged-in
I guess there is still some cleaning up to do on this as there are a few missing options, but it looks to be comprehensive and should help with further standardising themes.
Despite the obvious value of this though something just doesn’t sit right with me about creating core functions to output classes. I can’t put my finger on why I don’t like it at the moment, but as the concept is clearly here to stay I guess it doesn’t really matter. Enjoy the new classes.
Html 5 Gallery
6 comments
page 1305
Post Image The Easy Peasy Way
26 comments
page 1065
Quick N Dirty Bookmark Navigation
no comment
page 127
Html 5 Gallery
6 comments
page 1305
Html 5 Gallery
6 comments
page 1305
Post Image The Easy Peasy Way
26 comments
page 1065
Html 5 Gallery
6 comments
page 1305
What Wordpress Workflow Needs
3 comments
page 1226
Html 5 Gallery
6 comments
page 1305
Post Image The Easy Peasy Way
26 comments
page 1065
Post Image The Easy Peasy Way
26 comments
page 1065
Post Image The Easy Peasy Way
26 comments
page 1065
Post Image The Easy Peasy Way
26 comments
page 1065
Html 5 Gallery
6 comments
page 1305
Post Image The Easy Peasy Way
26 comments
page 1065
Fun With Sidebar Tabs Styling
2 comments
page 336
Fun With Sidebar Tabs Styling
2 comments
page 336
How To Add Sidebars To A Theme
10 comments
page 1053
Post Image The Easy Peasy Way
26 comments
page 1065
Html 5 Gallery
6 comments
page 1305
Wordpress Vs Graffiti
8 comments
page 95
Poll Daddy Reviewed
2 comments
page 42
Html 5 Gallery
6 comments
page 1305
Html 5 Gallery
6 comments
page 1305
Post Image The Easy Peasy Way
26 comments
page 1065
Quick N Dirty Post Exclusion
11 comments
page 124
Using Your Own Url Shortener
4 comments
page 1190
My Experience Of Flexx
4 comments
page 1026
Html 5 Gallery
6 comments
page 1305
Wordpress Chat
3 comments
page 1308
Quick N Dirty Post Exclusion
11 comments
page 124
1 query every 823 seconds, updated 1 seconds ago.
(__)
`
Jose
been adding the fuction from sandbox 1.6 to some custom themes, this kind of classes help so much :) great it's getting in wp2.8
(__)
`
WordPress News Report: iPhone, Widgets API, WordCamps in Hong Kong and China, International WordPress.tv « WordPress RSS
[...] What a body! [...]
(__)
`
Lorelle on WP: WordPress News Report: iPhone, Widgets API, WordCamps in Hong Kong and China, International WordPress.tv | Aslifm Blogu
[...] What a body! [...]
(__)
`
Wordpress 2.8 para Abril de 2009 | aNieto2K
[...] otro tag para nuestros themes que especificar
(__)
`
WordPress News Report: iPhone, Widgets API, WordCamps in Hong Kong and China, International WordPress.tv | WORDPRESS EXTENSIONS-PLUGINS-THEMES-TEMPLATES
[...] What a body! [...]
(__)
`
WordPress News Report: iPhone, Widgets API, WordCamps in Hong Kong and China, International WordPress.tv « Lorelle on WordPress
[...] What a body! [...]
(__)
`
WordPress News Summary: WordCamps, WordPress Meetups, WordPress PowerPoint, FeedBurner and Flash Warnings « WordPress RSS
[...] What a body! [...]
(__)
`
Otto
The idea was taken more or less directly from the Sandbox themes, which did this sort of thing as well. I think it's a good idea on the whole, because it standardizes several common theme tricks and removes a lot of the need for custom PHP code in themes to, for example, style posts by specific authors differently. End users have a hard time dealing with PHP, but can usually cope with simple CSS styling.
(__)
`
ovidiu
what about adding some of the features of this plugin: http://www.alistercameron.com/2007/01/04/wordpr... this plugin is brilliant in my opinion.
(__)
`
WordPress links week 7 – 2009 | WPStart.org – WordPress themes, plugins and news
[...] What a body! [...]
(__)
`
david
I've been thinking about the class stuff as well.
My basic feeling is this: I can think of a few tangible benefits–ease of styling being by far the most prominent–but no meaningful deficit. Perhaps I'm missing something, but until it's pointed out it me I won't complain.