Thord Daniel Hedengren - Smashing WordPress_ Beyond the Blog-Wiley (2014)

(avery) #1

138 PART II • Designing and Developing WordPress Themes


This indicates that whenever body_class() returns the single class, which is in single
post view, you get 48-pixel h2 headings, whereas whenever body_class() returns
class="archive", you get 36-pixel h2 headings.

Body class styling can be taken a long way because the addition of body classes depending on
whereabouts on a site you are is placed so high up in the hierarchy. Most themes designed
prior to the addition of the body_class() template tag won’t be able to truly put this to
good use, but if you reconsider your CSS code, you’ll see that you can control more of your
design from the classes passed to body rather than by adding classes to every element in the
template files.

The following classes are available (and are listed in order of importance), depending on
where you are on the site. Most likely, you don’t have to style them all:

◾ rtl
◾ home
◾ blog
◾ archive
◾ date
◾ search
◾ paged
◾ attachment
◾ error404
◾ single-postid-X (where X is the post ID)
◾ page-id-X (where X is the Page ID)
◾ attachmentid-X (where X is the attachment ID)
◾ attachment-MIME (where MIME is the MIME type)
◾ author
◾ author-USER (where USER is the author’s nice name)
◾ category
◾ category-X (where X is the category slug)
◾ tag
◾ tag-X (where X is the tag slug)
◾ page-parent
◾ page-child parent-pageid-X (where X is the Page ID)
◾ page-template page-template-FILE (where FILE is the template filename)
◾ search-results
◾ search-no-results
◾ logged-in
◾ paged-X (where X is the page number, referring to listings)
Free download pdf