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.
My Experience Of Flexx
4 comments
page 1026
Why You Should Try Netbeans
6 comments
page 973
Wpunlimited The Ultimate Wordpress Theme
3 comments
page 1141
Beware Wp Cache
8 comments
page 1310
Post Image The Easy Peasy Way
26 comments
page 1065
Wordpress 25 Exif Fields
12 comments
page 230
Html 5 Gallery
6 comments
page 1305
Divine Proportions
3 comments
page 145
Beware Wp Cache
8 comments
page 1310
Html 5 Gallery
6 comments
page 1305
Beware Wp Cache
8 comments
page 1310
Charcoal Theme Available For Wordpress
2 comments
page 959
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
Quick N Dirty Admin Login Screen
no comment
page 128
Wordpress Chat
one comment
page 1308
Html 5 Gallery
6 comments
page 1305
Html 5 Gallery
6 comments
page 1305
Silence Is Golden
3 comments
page 213
Questions About Habari For Wordpress Users
6 comments
page 424
Theming Habari Vs Wordpress
13 comments
page 440
My Experience Of Flexx
4 comments
page 1026
Plugin Update Fun With Photo Data 2
one comment
page 815
Post Image The Easy Peasy Way
26 comments
page 1065
Categories Vs Tags Either Neither Or Both
12 comments
page 7
Gaining Benefits From Plugins
8 comments
page 1167
Beware Wp Cache
8 comments
page 1310
Six Million Ways To Die Choose One
14 comments
page 1128
Post Image The Easy Peasy Way
26 comments
page 1065
Wordpress Chat
one comment
page 1308
Post Image The Easy Peasy Way
26 comments
page 1065
updated 1 seconds ago
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
[...] What a body! [...]
[...] What a body! [...]
[...] otro tag para nuestros themes que especificar
[...] What a body! [...]
[...] What a body! [...]
[...] What a body! [...]
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.
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.
[...] What a body! [...]
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.