<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Digging into WordPress &#187; CSS</title>
	<atom:link href="http://digwp.com/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://digwp.com</link>
	<description>Take your WordPress skills to the next level.</description>
	<lastBuildDate>Thu, 09 Feb 2012 19:03:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>WordPress Default CSS Styles</title>
		<link>http://digwp.com/2010/05/default-wordpress-css-styles-hooks/</link>
		<comments>http://digwp.com/2010/05/default-wordpress-css-styles-hooks/#comments</comments>
		<pubDate>Mon, 24 May 2010 08:52:22 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[stylesheets]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=2158</guid>
		<description><![CDATA[WordPress gives us full control over the presentation of our websites. We specify which classes and attributes to use in our template files, and then apply CSS using our theme&#8217;s custom stylesheet. Behind the scenes, WordPress generates its own classes and IDs, and applies them to specific HTML elements in theme files and database content. [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress gives us <em>full control</em> over the presentation of our websites. We specify which classes and attributes to use in our template files, and then apply <acronym title="Cascading Style Sheets">CSS</acronym> using our theme&rsquo;s custom stylesheet. Behind the scenes, <strong>WordPress generates its own classes and IDs</strong>, and applies them to specific <acronym title="Hypertext Markup Language">HTML</acronym> elements in theme files and database content. Having these default hooks available makes it <strong>super-easy</strong> to <strong>custom-style</strong> your theme&rsquo;s blockquotes, post images, widget items, and <em>much</em> more.</p>
<p>In addition to generating default classes for your site&rsquo;s &ldquo;front-end&rdquo; (public-facing) pages, WordPress also employs a default set of <acronym title="Cascading Style Sheets">CSS</acronym> attributes for the Admin, or &ldquo;back-end&rdquo; pages. If you&rsquo;ve ever delved into the convoluted <acronym title="Cascading Style Sheets">CSS</acronym> stylings of the WordPress Admin, you will understand why we focus <em>exclusively</em> on <strong>front-end attributes</strong> in this article. The goal is to include all classes and IDs generated for database content, theme template files, and default widget items.</p>
<p>Fortunately, most (if not all) of your <acronym title="WordPress">WP</acronym> <acronym title="Cascading Style Sheets">CSS</acronym> work happens at the &ldquo;theme&rdquo; or &ldquo;post&rdquo; level. And when you <em>do</em> need to style the Admin, it&rsquo;s usually easiest to just do it <em>en bloc</em> <a href="http://wordpress.org/extend/plugins/search.php?q=admin+theme&#038;sort=" title="Search the WP Plugin Directory for all 'admin theme' plugins">via plugin</a>. You can also do it <a href="http://codex.wordpress.org/Creating_Admin_Themes" title="Creating Admin Themes">the old-fashioned way</a>.</p>
<p><span id="more-2158"></span></p>
<h3>Different Types of Default WordPress Styles</h3>
<p>In this <a href="http://digwp.com/" title="Digging into WordPress">DiW</a> post, we assemble and dissect as many of the default <em>front-end</em> WordPress <acronym title="Cascading Style Sheets">CSS</acronym> attributes that we could find. It turns out there are many more automatically generated classes and IDs than you probably realize, including those for more commonly styled elements such as the following:</p>
<ul>
<li>Images included via WordPress&rsquo; <acronym title="What You See Is What You Get">WYSIWYG</acronym> Post Editor</li>
<li>Image <em>captions</em> and <em>galleries</em> included via the <acronym title="What You See Is What You Get">WYSIWYG</acronym> Post Editor</li>
<li>The <a href="http://digwp.com/2009/08/wordpress-body-class-plus/" title="Advanced WordPress Targeting with body_class_plus()">body_class()</a> and <a href="http://digwp.com/2010/03/add-classes-to-post_class/" title="Add Classes to post_class">post_class()</a> template tags</li>
<li>WordPress&rsquo; automatic &ldquo;smilies&rdquo;</li>
<li>WordPress&rsquo; default widgets</li>
</ul>
<p>Some of these features are used quite frequently, while others not so much. It&rsquo;s a good idea to cover your bases for these items, especially when producing <strong>publicly available themes</strong>. By including some <em>basic</em> styles for key <acronym title="Cascading Style Sheets">CSS</acronym> attributes, you ensure a more complete and rewarding experience for your theme&rsquo;s users (and <em>their</em> users as well).</p>
<p>Fortunately, not all of WordPress&rsquo; default <acronym title="Cascading Style Sheets">CSS</acronym> attributes <em>require</em> explicit styling. Many default classes and IDs are generated and included as a matter of <em>convenience</em>. Conversely, there some core styles that are <em>essential</em> for public themes. So to organize things, we have two somewhat arbitrary types of default attributes, &ldquo;essential&rdquo; or &ldquo;optional&rdquo; &ndash; and here they are now:</p>
<h4 id="wpcssmenu">Essential WordPress Styles</h4>
<p>These are default WordPress attributes that <em>should</em> be styled with <acronym title="Cascading Style Sheets">CSS</acronym>:</p>
<ul>
<li><a href="#wysiwyg">Default styles applied by WordPress&rsquo; <acronym title="What You See Is What You Get">WYSIWYG</acronym> editor</a></li>
<li><a href="#widgets">Default styles generated by WordPress&rsquo; default widgets</a></li>
<li><a href="#comment-styles">Comment styles</a> &ndash; threaded comments, specific comment styles, et al.</li>
<li><a href="#misc">Miscellaneous WordPress styles</a></li>
</ul>
<h4>Optional WordPress Styles</h4>
<p>These are default WordPress attributes that should be styled <em>only when needed</em>:</p>
<ul>
<li><a href="#pages">WordPress Page Listings</a></li>
<li><a href="#body_class"><acronym title="Cascading Style Sheets">CSS</acronym> attributes generated by <code>body_class()</code></a></li>
<li><a href="#post_class"><acronym title="Cascading Style Sheets">CSS</acronym> attributes generated by <code>post_class()</code></a></li>
<li><a href="#misc">Miscellaneous WordPress styles</a></li>
</ul>
<p>For each of these sections, we&rsquo;ll review the associated functionality and then present the default <acronym title="Cascading Style Sheets">CSS</acronym> styles generated and output by WordPress. It is ultimately <strong>up to you</strong> to decide the <em>best approach</em> for dealing with these default styles. If nothing else, it is wise to provide styles for WordPress&rsquo; <acronym title="What You See Is What You Get">WYSIWYG</acronym> Editor items and perhaps widgets, if enabled. This is functionality that users typically employ while working with their site.</p>
<p>For all of these <acronym title="Cascading Style Sheets">CSS</acronym> attributes, we are merely presenting the selectors devoid of any preset styles. Only the styles for the <acronym title="What You See Is What You Get">WYSIWYG</acronym> Editor are included, mostly because they are styled according to the <a href="http://codex.wordpress.org/CSS" title="WP Codex: CSS">WordPress Codex</a>. Everything else is entirely <em>up to you</em>.</p>
<h3 id="wysiwyg"><small>[ <a href="#wpcssmenu" title="Return to Menu">^</a> ]</small> WordPress CSS &#8211; WYSIWYG Editor Styles</h3>
<p>When you are working with WordPress&rsquo; <acronym title="What You See Is What You Get">WYSIWYG</acronym> Editor in the <strong>Edit Post</strong> screen, WordPress applies context-specific <acronym title="Cascading Style Sheets">CSS</acronym> attributes to certain elements when they are included in your post. For example, when inserting images, you can specify whether the images are floated left, right, or even centered. To do this, WordPress applies classes such as <code>alignleft</code>, <code>alignright</code>, or <code>aligncenter</code>. Without defining styles for WordPress&rsquo; default hooks, images and other elements may not display as intended.</p>
<p>Thus, at a <em>bare minimum</em>, if you are building a theme that will be used by the general public, it is wise to include the following <strong>basic styles</strong> for the items attributed via the <acronym title="What You See Is What You Get">WYSIWYG</acronym> Editor:</p>
<pre><code>/* == WordPress WYSIWYG Editor Styles == */

.entry-content img {
	margin: 0 0 1.5em 0;
	}
.alignleft, img.alignleft {
	margin-right: 1.5em;
	display: inline;
	float: left;
	}
.alignright, img.alignright {
	margin-left: 1.5em;
	display: inline;
	float: right;
	}
.aligncenter, img.aligncenter {
	margin-right: auto;
	margin-left: auto;
	display: block;
	clear: both;
	}
.alignnone, img.alignnone {
	/* not sure about this one */
	}
.wp-caption {
	margin-bottom: 1.5em;
	text-align: center;
	padding-top: 5px;
	}
.wp-caption img {
	border: 0 none;
	padding: 0;
	margin: 0;
	}
.wp-caption p.wp-caption-text {
	line-height: 1.5;
	font-size: 10px;
	margin: 0;
	}
.wp-smiley {
	margin: 0 !important;
	max-height: 1em;
	}
blockquote.left {
	margin-right: 20px;
	text-align: right;
	margin-left: 0;
	width: 33%;
	float: left;
	}
blockquote.right {
	margin-left: 20px;
	text-align: left;
	margin-right: 0;
	width: 33%;
	float: right;
	}
.gallery dl {}
.gallery dt {}
.gallery dd {}
.gallery dl a {}
.gallery dl img {}
.gallery-caption {}

.size-full {}
.size-large {}
.size-medium {}
.size-thumbnail {}</code></pre>
<p>Lots of good stuff there, but no predefined styles for some of the Gallery items, such as <code>.gallery</code>&nbsp;<code>dl</code> and <code>.size-thumbnail</code>, as seen near the end of the list. Also, if you are using <a href="http://perishablepress.com/press/2007/10/23/a-killer-collection-of-global-css-reset-styles/" title="A Killer Collection of Global CSS Reset Styles">reset styles</a> for margins and padding, you can strip out quite a few rules from this default set.</p>
<blockquote><p>Quick Tip: an easy way to ensure that everything is looking great is to simply create a test post in which you include each of the <acronym title="What You See Is What You Get">WYSIWYG</acronym> items. Then include this set of default styles and fine-tune as desired.</p></blockquote>
<p>As with most everything else WordPress-related, for more information on these default WordPress styles, check out the <a href="http://codex.wordpress.org/CSS#WordPress_Generated_Classes" title="WP Codex: WordPress Generated Classes">Codex</a>. The default selectors above basically define <acronym title="Cascading Style Sheets">CSS</acronym> styles for images, captions, galleries, blockquotes, and smilies &#038;ndash: in other words, all of the items that you can include using WordPress&rsquo; built-in <acronym title="What You See Is What You Get">WYSIWYG</acronym> Editor. </p>
<h3 id="misc"><small>[ <a href="#wpcssmenu" title="Return to Menu">^</a> ]</small> WordPress CSS &#8211; Miscellaneous Styles</h3>
<p>After styling the <em>essentials</em>, you may also want to keep an eye out for these miscellaneous WordPress classes:</p>
<pre><code>/* == WordPress CSS - Miscellaneous Styles == */

/* category links */
 li.categories {}  
 li.cat-item {}
 li.cat-item-{id} {}
 li.current-cat {}
 li.current-cat-parent {}
 ul.children {}

/* blogroll links */
.linkcat {}
.blogroll {}

/* read-more links */
.more-link {}</code></pre>
<p>Not all of them are going to be used in <em>every</em> theme, but they are used quite commonly, especially the <code>.read-more</code> class, which is frequently used for archive, category and tag pages. It may be wise to anticipate their presence to ensure that nothing is going to break your theme&rsquo;s design. Also, for more information on the category-links template tag, visit the <a href="http://codex.wordpress.org/Template_Tags/wp_list_categories" title="WP Codex: wp_list_categories">WP Codex: wp_list_categories</a>.</p>
<h3 id="pages"><small>[ <a href="#wpcssmenu" title="Return to Menu">^</a> ]</small> WP CSS &#8211; Page Listings</h3>
<p>If you are using WordPress&rsquo; built-in page-listing functionality provided by the <code>wp_list_pages()</code> and <code>wp_page_menu()</code> template tags, there are a variety of items that should be styled. These may look like a lot of work, but once you get the pattern down, it goes pretty quickly. Hopefully the following list will prove a useful reference during your next page-list styling session:</p>
<pre><code>/* == WP CSS - Page Listings == */

.pagenav {}               /* outermost list item */
.page_item {}             /* any page item */
.page-item-{id} {}        /* specific page id */
.current_page_item {}     /* current page */
.current_page_parent {}   /* parent of current page */
.current_page_ancestor {} /* any ancestor of current page */

.pagenav ul,
.pagenav .current_page_item ul,
.pagenav .current_page_ancestor ul,
.pagenav .current_page_ancestor .current_page_item ul,
.pagenav .current_page_ancestor .current_page_ancestor ul,
.pagenav .current_page_ancestor .current_page_ancestor .current_page_item ul,
.pagenav .current_page_ancestor .current_page_ancestor .current_page_ancestor ul {}

.pagenav  ul ul,
.pagenav .current_page_item ul ul,
.pagenav .current_page_ancestor ul ul,
.pagenav .current_page_ancestor .current_page_item ul ul,
.pagenav .current_page_ancestor .current_page_ancestor ul ul {}
.pagenav .current_page_ancestor .current_page_ancestor .current_page_item ul ul, 
.pagenav .current_page_ancestor .current_page_ancestor .current_page_ancestor ul ul {}</code></pre>
<p>Again, the <em>easiest</em> way to understand this spaghetti is to create a list by including <code>wp_list_pages()</code> in a theme template file, and define a big red border (or whatever) for each declaration block. Check the results and you should quickly recognize the pattern. For more information on the template tags used to generate these rules, go to Codex: </p>
<ul>
<li><a href="http://codex.wordpress.org/Template_Tags/wp_list_pages" title="WP Codex: Template Tags/wp_list_pages">wp_list_pages()</a></li>
<li><a href="http://codex.wordpress.org/Template_Tags/wp_page_menu" title="WP Codex: Template Tags/wp_page_menu">wp_page_menu()</a></li>
</ul>
<p>You may also want to check out some <a href="http://digwp.com/2009/07/delicious-recipes-wordpress-page-menus/" title="Delicious Recipes for WordPress Page Menus and Page Listings">delicious recipes for WordPress page navigation</a>, which provide everything you need to create the perfect page navigation menus for your website. <code>&lt;/hype&gt;</code></p>
<h3 id="widgets"><small>[ <a href="#wpcssmenu" title="Return to Menu">^</a> ]</small> WordPress CSS &#8211; Default WordPress Widgets</h3>
<p>There are literally <em>thousands</em> of widgets available to WordPress users, but there is a handful of very common widgets that are frequently used with widgetized themes. If you are planning on <a href="http://digwp.com/2010/02/how-to-widgetize-wordpress-theme/" title="How to Widgetize Your WordPress Theme in 2 Steps">widgetizing your theme</a>, you should include some styles for some of the more popular widgets. Many of the widgets included with the retiring <em>Kubrick</em> theme have become very common, if not <em>expected</em>:</p>
<p><img src="http://digwp.com/wp-content/blog-images/kubrick-theme-widgets.gif" alt="[ Kubrick Widgets ]" /></p>
<p>As the theme designer, you will decide which (if any) widgets to include in your theme, so you will know <em>exactly</em> which styles to apply. Here are the generic rules for some of the more common WordPress widgets:</p>
<pre><code>/* == WordPress CSS - Default WordPress Widgets == */

.widget {}

/* links widget */
.widget_links {}
.widget_links ul {}
.widget_links ul li {}
.widget_links ul li a {}

/* meta widget */
.widget_meta {}
.widget_meta ul {}
.widget_meta ul li {}
.widget_meta ul li a {}

/* pages widget */
.widget_pages {}
.widget_pages ul {}
.widget_pages ul li {}
.widget_pages ul li a {}

/* recent-posts widget */
.widget_recent_entries {}
.widget_recent_entries ul {}
.widget_recent_entries ul li {}
.widget_recent_entries ul li a {}

/* archives widget */
.widget_archive {}
.widget_archive ul {}
.widget_archive ul li {} 
.widget_archive ul li a {}
.widget_archive select {}
.widget_archive option {}

/* tag-cloud widget */
.widget_links {}
.widget_links li:after {}
.widget_links li:before {}
.widget_tag_cloud {}
.widget_tag_cloud a {}
.widget_tag_cloud a:after {}
.widget_tag_cloud a:before {}

/* calendar widget */
.widget_calendar {}
#calendar_wrap {}
#calendar_wrap th {}
#calendar_wrap td {}
#wp-calendar tr td {}
#wp-calendar caption {}
#wp-calendar a {}
#wp-calendar #today {}
#wp-calendar #prev {}
#wp-calendar #next {}
#wp-calendar #next a {}
#wp-calendar #prev a {}

/* category widget */
.widget_categories {}
.widget_categories ul {}
.widget_categories ul li {} 
.widget_categories ul ul.children {}
.widget_categories a {}
.widget_categories select{}
.widget_categories select#cat {}
.widget_categories select.postform {}
.widget_categories option {}
.widget_categories .level-0 {}
.widget_categories .level-1 {}
.widget_categories .level-2 {}
.widget_categories .level-3 {}

/* recent-comments widget */
.recentcomments {}
#recentcomments {}
#recentcomments li {}
#recentcomments li a {}
.widget_recent_comments {}

/* search widget */
#searchform {}
.widget_search {}
.screen-reader-text {}

/* text widget */
.textwidget {}
.widget_text {}
.textwidget p {}</code></pre>
<p>That&rsquo;s obviously a <em>lot</em> of work for any designer, but there are many similar elements that would probably look best with matching styles. For example, instead of multiple declarations for list elements such as <code>.widget_archive ul li</code>, <code>.widget_pages ul li</code>, and <code>.widget_recent_entries ul li</code>, we can simplify by combining them into a single declaration, for example:</p>
<p><code>.widget_pages ul li,</code><br />
<code>.widget_archive ul li, </code><br />
<code>.widget_recent_entries ul li {}</code></p>
<p>In other words, when it comes to styling widgets, there&rsquo;s a lot of repetition that may be consolidated and streamlined in your stylesheet. As you apply styles for WordPress&rsquo; default widgets, keep an eye out for exploitable selector patterns and similar styles that may be combined to save time and effort.</p>
<h3 id="comment-styles"><small>[ <a href="#wpcssmenu" title="Return to Menu">^</a> ]</small> WordPress CSS &#8211; Comment Styles</h3>
<p>Styling comments is the bane of WordPress theme designers, especially when threaded/nested comments are enabled. The deeper they go, the more time you&rsquo;re going to spend with them, but thankfully WordPress makes things a little easier by providing plenty of precise <acronym title="Cascading Style Sheets">CSS</acronym> hooks. Of course, if threaded comments are disabled, there is no need to bother with <em>most</em> of these classes. But when they <em>are</em> used, many of the following selectors should define style:</p>
<pre><code>/* == WP CSS - Comment Styles == */

.commentlist .reply {}
.commentlist .reply a {}

.commentlist .alt {}
.commentlist .odd {}
.commentlist .even {}
.commentlist .thread-alt {}
.commentlist .thread-odd {}
.commentlist .thread-even {}
.commentlist li ul.children .alt {}
.commentlist li ul.children .odd {}
.commentlist li ul.children .even {}

.commentlist .vcard {}
.commentlist .vcard cite.fn {}
.commentlist .vcard span.says {}
.commentlist .vcard img.photo {}
.commentlist .vcard img.avatar {}
.commentlist .vcard cite.fn a.url {}

.commentlist .comment-meta {} 
.commentlist .comment-meta a {}
.commentlist .commentmetadata {}
.commentlist .commentmetadata a {}

.commentlist .parent {}
.commentlist .comment {}
.commentlist .children {}
.commentlist .pingback {}
.commentlist .bypostauthor {}
.commentlist .comment-author {}
.commentlist .comment-author-admin {}

.commentlist {}
.commentlist li {}
.commentlist li p {}
.commentlist li ul {}
.commentlist li ul.children li {}
.commentlist li ul.children li.alt {}
.commentlist li ul.children li.byuser {}
.commentlist li ul.children li.comment {}
.commentlist li ul.children li.depth-{id} {}
.commentlist li ul.children li.bypostauthor {}
.commentlist li ul.children li.comment-author-admin {}

#cancel-comment-reply {}
#cancel-comment-reply a {}</code></pre>
<p>These are all of the classes and IDs that I could find, and they all seem to be pretty self-explanatory, especially after using them a few times. Even so, consider the collection a work in progress. As new information is discovered, the list will continue to improve (hypothetically speaking). Many of these selectors target markup elements generated via WordPress&rsquo; built-in <a href="http://codex.wordpress.org/Template_Tags/wp_list_comments" title="Template Tags/wp_list_comments">wp_list_comments()</a> template tag. Even when using a <a href="http://digwp.com/2010/02/custom-comments-html-output/" title="Custom Comments HTML Output">custom callback function</a> for your comments loop, many of these <acronym title="Cascading Style Sheets">CSS</acronym> classes will be available for your styling convenience.</p>
<h3 id="body_class"><small>[ <a href="#wpcssmenu" title="Return to Menu">^</a> ]</small> WordPress CSS &#8211; body_class()</h3>
<p>As of version 2.5, WordPress provides the <code>body_class()</code> template tag, which is included in the <code>&lt;body&gt;</code> element of your theme&rsquo;s markup. When included, this tag outputs a variety of context-dependent class names that facilitate styling different types of page views. We talk more about <code>body_class()</code> <a href="http://digwp.com/2009/05/unique-body-ids-for-your-pages/" title="Unique Body ID’s for your Pages">here</a> and <a href="http://digwp.com/2009/08/wordpress-body-class-plus/" title="Advanced WordPress Targeting with body_class_plus()">here</a>, but for now, let&rsquo;s look at the different classes WordPress generates for this powerful tag:</p>
<pre><code>/* == WP CSS - body_class() == */

.rtl {}
.home {}
.blog {}
.archive {}
.date {}
.search {}
.paged {}
.attachment {}
.error404 {}
.single postid-(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) {}</code></pre>
<p>As you can see, these classes enable us to easily target elements on any specific type of page. For example, if you want to customize the presentation of your search results, you could define your styles using the <code>.search-results</code> class. This flexibility offers greater control over the granular construction of your WordPress theme. For more information on the <code>body_class()</code> tag, check out the <a href="http://codex.wordpress.org/Template_Tags/body_class" title="Template Tags/body_class">WordPress Codex</a>.</p>
<h3 id="post_class"><small>[ <a href="#wpcssmenu" title="Return to Menu">^</a> ]</small> WordPress CSS &#8211; post_class()</h3>
<p>As with <code>body_class()</code>, the <code>post_class()</code> template tag outputs a variety of context-dependent class names for your posts. The <code>post_class()</code> tag makes it easy to target and style specific posts and post-types, as well as posts from specific categories or tags. Here are the different class names automatically generated by <code>post_class()</code>:</p>
<pre><code>/* == WP CSS - post_class() == */

.post-id {}
.post {}
.page {}
.attachment {}
.sticky {}
.hentry {}
.category-misc {}
.category-example {}
.tag-news {}
.tag-wordpress {}
.tag-markup {}</code></pre>
<p>Again, these classes seem pretty self-explanatory, but if anyone happens to know the definition of the <code>.hentry</code> class, it would be nice to know &ndash; I couldn&rsquo;t find anything, and sadly didn&rsquo;t take time to test. Basically, these classes enable you to define styles for specific types of posts, attachments, stickies, categories and tags. You can also <a href="http://digwp.com/2010/03/add-classes-to-post_class/" title="Add Classes to post_class">include your own classes to post_class()</a>, and even <a href="http://digwp.com/2010/01/include-the-category-id-via-post_class/" title="Include the Category ID via post_class">include current category IDs</a>. For more information on the <code>post_class()</code> tag, check out the <a href="http://codex.wordpress.org/Template_Tags/post_class" title="Template Tags/post_class">WordPress Codex</a>.</p>
<h3>Call for updates</h3>
<p>So what&rsquo;s missing? Notice any errors? I did my best to research everything and organize everything as accurately as possible, but this turned out to be a bit more insane than I had planned, and so there is definitely room for improvement. If you see anything that is inaccurate or incomplete, please advise in the comments. It would be great to fine-tune a <em>complete</em> reference for all of WordPress&rsquo; default <acronym title="Cascading Style Sheets">CSS</acronym> styles and hooks all in one place.</p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/05/default-wordpress-css-styles-hooks/">Permalink</a> | <a href="http://digwp.com/2010/05/default-wordpress-css-styles-hooks/#comments">27 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/05/default-wordpress-css-styles-hooks/&title=WordPress Default CSS Styles">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/css/" rel="tag">CSS</a>, <a href="http://digwp.com/tag/stylesheets/" rel="tag">stylesheets</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/05/default-wordpress-css-styles-hooks/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>6 Ways to Display WordPress Post Content in Multiple Columns</title>
		<link>http://digwp.com/2010/03/wordpress-post-content-multiple-columns/</link>
		<comments>http://digwp.com/2010/03/wordpress-post-content-multiple-columns/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 08:25:45 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[posts]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1647</guid>
		<description><![CDATA[Most blogs display their content in single columns, but it&#8217;s also possible to display content in multiple columns. Multiple-column layouts are perfect for newspaper and magazine-style themes. Here are six ways of getting the job done. Using CSS3 and progressive enhancement Multiple columns by filtering the_content More flexible multiple columns Multiple loops displayed in multiple [...]]]></description>
			<content:encoded><![CDATA[<p>Most blogs display their content in single columns, but it&rsquo;s also possible to display content in <strong>multiple columns</strong>. Multiple-column layouts are perfect for newspaper and magazine-style themes. Here are six ways of getting the job done.</p>
<ol id="post-menu">
<li><a href="http://digwp.com/2010/03/wordpress-post-content-multiple-columns/#css3">Using CSS3 and progressive enhancement</a></li>
<li><a href="http://digwp.com/2010/03/wordpress-post-content-multiple-columns/#filter">Multiple columns by filtering the_content</a></li>
<li><a href="http://digwp.com/2010/03/wordpress-post-content-multiple-columns/#flexible">More flexible multiple columns</a></li>
<li><a href="http://digwp.com/2010/03/wordpress-post-content-multiple-columns/#loops">Multiple loops displayed in multiple columns</a></li>
<li><a href="http://digwp.com/2010/03/wordpress-post-content-multiple-columns/#horizontal">Display your posts in horizontal display order with two columns</a></li>
<li><a href="http://digwp.com/2010/03/wordpress-post-content-multiple-columns/#bonus">Bonus: Display your category list in two columns</a></li>
</ol>
<h3 id="css3">1. Using CSS3 and progressive enhancement</h3>
<p>I think the easiest way to display your content in multiple columns is to apply a little <acronym title="Cascading Style Sheets">CSS</acronym>3 in progressively enhancing fashion. Let&rsquo;s say you have the following markup:</p>
<pre><code>&lt;div class="content"&gt;
	&lt;p&gt;Lorem ipsum..&lt;/p&gt;
	&lt;p&gt;Lorem ipsum..&lt;/p&gt;
	&lt;p&gt;Lorem ipsum..&lt;/p&gt;
&lt;/div&gt;</code></pre>
<p><span id="more-1647"></span></p>
<p>We can add the following <acronym title="Cascading Style Sheets">CSS</acronym> to display the content in multiple columns:</p>
<pre><code>.content {
	  -moz-column-count: 3;
	  -moz-column-gap: 10px;
	  -moz-column-rule: none;
	  -webkit-column-count: 3;
	  -webkit-column-gap: 10px;
	  -webkit-column-rule: none;
	column-count: 3;
	column-gap: 10px;
	column-rule: none;
	}</code></pre>
<p>This will display your content in three columns with a <code>10px</code> gap between each. This technique is a great way to enhance the display of your content for people running cool modern browsers like Safari and Firefox. What about folks visiting with Internet Exploder or older browsers? They will see your content displayed in a single column, just like they would have before you applied the multiple columns. <strong>Note</strong> that you can specify any number of coulmns and any width for the gap.</p>
<h3 id="filter">2. Multiple columns by filtering the_content</h3>
<p>If you need something a little more &ldquo;universal&rdquo; than what is currently available with <acronym title="Cascading Style Sheets">CSS</acronym>3, we can always dig into our template files, modify things at the <acronym title="PHP: Hypertext Preprocessor">PHP</acronym>/<acronym title="(eXtensible) Hypertext Markup Language">(X)HTML</acronym> level, and then style accordingly. Here is the technique provided by <a href="http://www.kriesi.at/archives/wordpress-display-content-in-multiple-columns" title="Wordpress: Display Content in multiple Columns">Kriesi.at</a>:</p>
<pre><code>function my_multi_col($content) {

	$columns = explode('&lt;h2&gt;', $content);
	$i = 0;

	foreach ($columns as $column) {
		if (($i % 2) == 0) {
			$return .= '&lt;div class="content_left"&gt;'."\n";
			if ($i &gt; 1) {
				$return .= "&lt;h2&gt;";
			} else {
				$return .= '&lt;div class="content_right"&gt;'."\n &lt;h2&gt;";
			}
			$return .= $column;
			$return .= '&lt;/p&gt;&lt;/div&gt;';
			$i++;
		}
		if(isset($columns[1])) {
	    		$content = wpautop($return);
		} else {
	    		$content = wpautop($content);
		}
		echo $content;
	}
}
add_filter('the_content', 'my_multi_col');</code></pre>
<p>Just place that into your active theme&rsquo;s <code>functions.php</code> file and then apply the following <acronym title="Cascading Style Sheets">CSS</acronym>:</p>
<pre><code>.content_right, .content_left{
	float: left;
	width: 45%;
	}
.content_left{
	padding-right: 5%;
	}</code></pre>
<p>Once implemented, this multi-column technique creates a a column for each instance of <code>&lt;h2&gt;</code> found within the post content. Thus, be sure to limit the number of <code>&lt;h2&gt;</code> elements to two in order to avoid layout breakage. <strong>Note</strong> that you could also modify the code to use a different element if the <code>&lt;h2&gt;</code> tag isn&rsquo;t good for you. Multiple columns doesn&rsquo;t get much easier, but just in case you need an alternate method for whatever reason, read on for some more great techniques.</p>
<h3 id="flexible">3. More flexible multiple columns</h3>
<p>The previous method works nice for two columns and no fuss, but for three or more columns we&rsquo;re going to need something a little more robust. fortunately, <a href="http://www.robsearles.com/2009/07/05/wordpress-multiple-content-columns/" title="Wordpress: Multiple Content Columns">Rob Searles</a> shares a technique that allows any number of columns with completely different content in each. This technique creates columns based on multiple instances of the <code>&lt;!--</code><code>more--&gt;</code> tag. There are several caveats, so check the orginal article for all the details.</p>
<p>Here are the steps involved in implementing this technique:</p>
<ol>
<li>Add the <code>my_multi_col_v2</code> function to your <code>functions.php</code> file</li>
<li>Add another snippet to your theme template file, for example <code>page.php</code></li>
<li>Add some <acronym title="Cascading Style Sheets">CSS</acronym> to format the markup into columns</li>
<li>Add a couple of <code>&lt;!--</code><code>more--&gt;</code> tags in your post or page to create the three columns</li>
</ol>
<p><strong>1.</strong> Let&rsquo;s go through these steps, beginning with the main function that you should place into your theme&rsquo;s <code>functions.php</code> file:</p>
<pre><code>function my_multi_col_v2($content){
	// run through a couple of essential tasks to prepare the content
	$content = apply_filters('the_content', $content);
	$content = str_replace(']]&gt;', ']]&amp;gt;', $content);
 
	// the first "more" is converted to a span with ID
	$columns = preg_split('/(&lt;span id="more-\d+"&gt;&lt;\/span&gt;)|(&lt;!--more--&gt;)&lt;\/p&gt;/', $content);
	$col_count = count($columns);
 
	if($col_count &gt; 1) {
		for($i=0; $i&lt;$col_count; $i++) {
			// check to see if there is a final &lt;/p&gt;, if not add it
			if(!preg_match('/&lt;\/p&gt;\s?$/', $columns[$i]) )  {
				$columns[$i] .= '&lt;/p&gt;';
			}
			// check to see if there is an appending &lt;/p&gt;, if there is, remove
			$columns[$i] = preg_replace('/^\s?&lt;\/p&gt;/', '', $columns[$i]);
			// now add the div wrapper
			$columns[$i] = '&lt;div class="dynamic-col-'.($i+1).'"&gt;'.$columns[$i].'&lt;/div&gt;';
		}
		$content = join($columns, "\n").'&lt;div class="clear"&gt;&lt;/div&gt;';
	}
	else {
		// this page does not have dynamic columns
		$content = wpautop($content);
	}
	// remove any left over empty &lt;p&gt; tags
	$content = str_replace('&lt;p&gt;&lt;/p&gt;', '', $content);
	return $content;
}</code></pre>
<p><strong>2.</strong> Once that&rsquo;s in place, replace your <code>the_content()</code> tag with the following code:</p>
<pre><code>$content = get_the_content('',FALSE,''); // arguments remove 'more' text
echo my_multi_col_v2($content);</code></pre>
<p><strong>3.</strong> The last bit of code that we need to setup is the <acronym title="Cascading Style Sheets">CSS</acronym> to make it all sweet:</p>
<pre><code>/* dynamic columns */
div.dynamic-col-1 { float: left; width: 38%; padding-right: 2%;}
div.dynamic-col-2 { float: left; width: 38%;padding-right: 2%;}
div.dynamic-col-3 { float: left; width: 20%;}
div.clear { clear: both; }</code></pre>
<p><strong>4.</strong> And last but not least, remember to add the two <code>&lt;!--</code><code>more--&gt;</code> tags in your post/page content to create the three columns.</p>
<p>That&rsquo;s all there is to it. Pretty good stuff, but even so, there are even more alternatives available. next we&rsquo;ll look at a technique for displaying multiple loops in multiple columns.</p>
<h3 id="loops">4. Multiple loops displayed in multiple columns</h3>
<p>Not too long ago, I wrote a post at Perishable Press explaining <a href="http://perishablepress.com/press/2008/09/01/multiple-loops-and-multiple-columns-with-wordpress/" title="Multiple Loops and Multiple Columns with WordPress, (X)HTML and CSS">how to display multiple loops with multiple columns</a>. The final product will look display something like this:</p>
<ul>
<li>First column, first loop: display posts #1-5</li>
<li>Second column, second loop: display posts #6-10</li>
<li>Third column, third loop: display posts #11-15</li>
</ul>
<p>Using WordPress and a little <acronym title="Cascading Style Sheets">CSS</acronym>, this configuration is relatively easy to accomplish. Let&rsquo;s cut right to the chase..</p>
<h4>Step 1: Setup the multiple loops</h4>
<p>The first thing we want to do is replace the standard WordPress loop with the following code:</p>
<pre><code>// FIRST LOOP: display posts 1 thru 5
&lt;?php query_posts('showposts=5'); ?&gt;
&lt;?php $posts = get_posts('numberposts=5&amp;offset=0'); foreach ($posts as $post) : start_wp(); ?&gt;
&lt;?php static $count1 = 0; if ($count1 == "5") { break; } else { ?&gt;

&lt;?php the_title(); ?&gt;
&lt;?php the_content(); ?&gt;

&lt;?php $count1++; } ?&gt;
&lt;?php endforeach; ?&gt;


// SECOND LOOP: display posts 6 thru 10
&lt;?php query_posts('showposts=5'); ?&gt;
&lt;?php $posts = get_posts('numberposts=5&amp;offset=5'); foreach ($posts as $post) : start_wp(); ?&gt;
&lt;?php static $count2 = 0; if ($count2 == "5") { break; } else { ?&gt;

&lt;?php the_title(); ?&gt;
&lt;?php the_content(); ?&gt;

&lt;?php $count2++; } ?&gt;
&lt;?php endforeach; ?&gt;


// THIRD LOOP: display posts 11 thru 15
&lt;?php query_posts('showposts=5'); ?&gt;
&lt;?php $posts = get_posts('numberposts=5&amp;offset=10'); foreach ($posts as $post) : start_wp(); ?&gt;
&lt;?php static $count3 = 0; if ($count3 == "5") { break; } else { ?&gt;

&lt;?php the_title(); ?&gt;
&lt;?php the_content(); ?&gt;

&lt;?php $count3++; } ?&gt;
&lt;?php endforeach; ?&gt;</code></pre>
<p>That&rsquo;s the juice right there. We have three loops, each displaying five posts. The first loop displays the first five posts, the second loop displays the next five posts, and the third loop displays the next five posts. Thus, this multiple-loop configuration displays the most recent 15 posts, each of which being unique. <a href="http://perishablepress.com/press/2008/09/01/multiple-loops-and-multiple-columns-with-wordpress/" title="Multiple Loops and Multiple Columns with WordPress, (X)HTML and CSS">See the original post</a> for more information, options and details.</p>
<h4>Step 2: Markup your theme template file(s)</h4>
<p>Now that we have the <acronym title="PHP: Hypertext Preprocessor">PHP</acronym> in place, we are ready to add the <acronym title="(eXtensible) Hypertext Markup Language">(X)HTML</acronym> markup required for the final three-column configuration. There are many ways to accomplish this, this is merely one of them:</p>
<pre><code>&lt;div id="column_01"&gt;

	&lt;!-- FIRST LOOP --&gt;

&lt;/div&gt;

&lt;div id="column_wrap"&gt;

	&lt;div id="column_02"&gt;

		&lt;!-- SECOND LOOP --&gt;

	&lt;/div&gt;
	&lt;div id="column_03"&gt;

		&lt;!-- THIRD LOOP --&gt;
	
	&lt;/div&gt;

&lt;/div&gt;</code></pre>
<p>Here, each of the three loops will be placed into its own <code>div</code>, which then will be styled with a little <acronym title="Cascading Style Sheets">CSS</acronym> to transform it into one of the three columns. Note that you may want to change the <code>id</code> names of the divisions to better represent the particular semantics of your document. Now let&rsquo;s move on to the <acronym title="Cascading Style Sheets">CSS</acronym>..</p>
<h4>Step 3: Styling the columns with CSS</h4>
<p>The final step in the tutorial is to style the markup with <acronym title="Cascading Style Sheets">CSS</acronym>. Nothing too fancy, really. Creating the columns is merely a matter of floating the individual divs and applying a width to each of them:</p>
<pre><code>/* three column layout */
div#column_01 {
	float: left;
	clear: none;
	width: 30%;
	}
div#column_wrap {
	float: right;
	clear: none;
	width: 60%;
	}
	div#column_02 {
		float: left;
		clear: none;
		width: 45%;
		}
	div#column_03 {
		float: right;
		clear: none;
		width: 45%;
		}</code></pre>
<p>The trick here is to use <code>width</code> values that will create the correct column widths. The values used in the example produce three columns of <em>approximately</em> equal width. Again, for more information on the details of this technique, see the original post.</p>
<p>Once you get everything setup, your posts should display your multiple-loop content in multiple columns, with each column showing the contents of a different loop. This is a great way to customize your theme, making it possible to present lots of disparate information within an easy-to-understand layout. Even so, this technique may not do it for you either. If so, we&rsquo;ve got a couple more WordPress tricks up our sleeve!</p>
<h3 id="horizontal">5. Display your posts in horizontal display order with two columns</h3>
<p>That&rsquo;s a mouthful, isn&rsquo;t it? What we&rsquo;re doing in this section is changing the order in which your two-column posts appear on the page. Typically, your two-column layout displays posts like this:</p>
<pre><code>Post #1   |   Post #4
Post #2   |   Post #5
Post #3   |   Post #6
 .        |    .
 .        |    .
 .        |    .</code></pre>
<p>All of the multi-column methods we&rsquo;ve discussed so far result in this sort of post-display order. So now we want to change things up a bit and display our two-column posts in <em>horizontal</em> display order, like so:</p>
<pre><code>Post #1   |   Post #2
Post #3   |   Post #4
Post #5   |   Post #6
 .        |    .
 .        |    .
 .        |    .</code></pre>
<p>How is this accomplished? As explained in my <a href="http://perishablepress.com/press/2008/08/04/two-column-horizontal-sequence-wordpress-post-order/" title="Horizontally Sequenced Display Order for WordPress Posts in Two Columns">horizontal-display tutorial</a>, this is easily accomplished using two default loops and the <code>rewind_posts()</code> function. The first loop will display the posts in the first column, while the second loop will display the posts in the second column. To do this, we use <acronym title="PHP: Hypertext Preprocessor">PHP</acronym>&rsquo;s <a  href="http://us.php.net/operators.arithmetic" title="PHP: Arithmetic Operators - Manual">modulus operator</a> to filter out every other post from the first loop, which will display posts in horizontal order.</p>
<p>To make this happen, first replace your default WordPress loop with the following code:</p>
<pre><code>&lt;?php if (have_posts()) : while(have_posts()) : $i++; if(($i % 2) == 0) : $wp_query-&gt;next_post(); else : the_post(); ?&gt;

&lt;div id="left-column"&gt;
&lt;h1&gt;&lt;?php the_permalink(); ?&gt;&lt;/h1&gt;
&lt;?php the_content(); ?&gt;
&lt;/div&gt;

&lt;?php endif; endwhile; else: ?&gt;
&lt;div&gt;Alternate content&lt;/div&gt;
&lt;?php endif; ?&gt;

&lt;?php $i = 0; rewind_posts(); ?&gt;

&lt;?php if (have_posts()) : while(have_posts()) : $i++; if(($i % 2) !== 0) : $wp_query-&gt;next_post(); else : the_post(); ?&gt;

&lt;div id="right-column"&gt;
&lt;h1&gt;&lt;?php the_permalink(); ?&gt;&lt;/h1&gt;
&lt;?php the_content(); ?&gt;
&lt;/div&gt;

&lt;?php endif; endwhile; else: ?&gt;
&lt;div&gt;Alternate content&lt;/div&gt;
&lt;?php endif; ?&gt;</code></pre>
<p>With that code in place, oddly numbered posts will appear within a division identified with an attribute of <code>id="left-column"</code>. Likewise, even-numbered posts will appear within a division identified with an attribute of <code>id="right-column"</code>. Thus, we may apply the following <acronym title="Cascading Style Sheets">CSS</acronym> to position the divisions as two adjacent columns:</p>
<pre><code>div#left-column {
	width: 333px;
	float: left;
	clear: none;
	}
div#right-column {
	width: 333px;
	float: right;
	clear: none;
	}</code></pre>
<p>Of course, when it comes to configuring the WordPress loop and styling your page with <acronym title="Cascading Style Sheets">CSS</acronym>,<br />
anything is possible. Feel free to experiment and adapt this technique to suit your own diabolical purposes&nbsp;;) As with the other methods described in this <acronym title="Digging into WordPress">DiW</acronym> post, much more information is available for this technique at the <a href="http://perishablepress.com/press/2008/08/04/two-column-horizontal-sequence-wordpress-post-order/" title="Horizontally Sequenced Display Order for WordPress Posts in Two Columns">original article</a>, including a nice, <acronym title="Cascading Style Sheets">CSS</acronym>-only method that is sure to leave you breathless.</p>
<h3 id="bonus">6. Bonus: Display your category list in two columns</h3>
<p>Using a little <acronym title="PHP: Hypertext Preprocessor">PHP</acronym> magic, we can get WordPress&rsquo; <code>wp_list_categories()</code> to display our <strong>categories in two columns</strong>. As <a href="http://www.blogohblog.com/10-wordpress-hacks-to-make-your-life-even-easier/" title="10 WordPress Hacks to Make Your Life Even Easier">Blog Oh Blog</a> explains, all you need is the following code placed in your theme file:</p>
<pre><code>&lt;?php // display categories in two columns
$cats = explode('&lt;br /&gt;', wp_list_categories('title_li=&amp;echo=0&amp;depth=1&amp;style=none'));
$cat_n = count($cats) - 1;
for ($i = 0; $i &lt; $cat_n; $i++):
	if ($i &lt; $cat_n/2):
		$cat_left = $cat_left.'&lt;li&gt;'.$cats[$i].'&lt;/li&gt;';
	elseif ($i &gt;= $cat_n/2):
		$cat_right = $cat_right.'&lt;li&gt;'.$cats[$i].'&lt;/li&gt;';
	endif;
endfor; ?&gt;

&lt;ul class="left"&gt;
	&lt;?php echo $cat_left; ?&gt;
&lt;/ul&gt;
&lt;ul class="right"&gt;
	&lt;?php echo $cat_right; ?&gt;
&lt;/ul&gt;</code></pre>
<p>Just use that code where you would like the categories to appear and enjoy the results.</p>
<h3>Wrapping it up</h3>
<p>Hopefully these techniques will inspire and enable you to break out of the &ldquo;single-column&rdquo; mindset and explore some multi-column possibilities. Using multiple columns for your content is a great way to enhance the visual appeal of your design and readability of your content.</p>
<p>There is SO much you can do with WordPress, <acronym title="PHP: Hypertext Preprocessor">PHP</acronym>, <acronym title="(eXtensible) Hypertext Markup Language">(X)HTML</acronym>, and <acronym title="Cascading Style Sheets">CSS</acronym>. The possibilities are endless indeed. The multiple-column techniques presented in this article provide a great starting point for creating more elaborate and sophisticated page layouts. So experiment, have fun, and be safe!!</p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/03/wordpress-post-content-multiple-columns/">Permalink</a> | <a href="http://digwp.com/2010/03/wordpress-post-content-multiple-columns/#comments">30 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/03/wordpress-post-content-multiple-columns/&title=6 Ways to Display WordPress Post Content in Multiple Columns">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/css/" rel="tag">CSS</a>, <a href="http://digwp.com/tag/loop/" rel="tag">loop</a>, <a href="http://digwp.com/tag/php/" rel="tag">PHP</a>, <a href="http://digwp.com/tag/posts/" rel="tag">posts</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/03/wordpress-post-content-multiple-columns/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>BLANK WordPress Theme</title>
		<link>http://digwp.com/2010/02/blank-wordpress-theme/</link>
		<comments>http://digwp.com/2010/02/blank-wordpress-theme/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 15:43:26 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Theme]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[free]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=981</guid>
		<description><![CDATA[There are many like it, but this one is mine. I have a &#8220;blank&#8221; WordPress theme for myself, because I make a lot of WordPress themes. Starting from Kubrick, or any other pre-made theme, would be absurd. There is to much stuff there that would to be stripped out or fought against to be useful. [...]]]></description>
			<content:encoded><![CDATA[<p>There are many like it, but this one is mine. </p>
<p>I have a &#8220;blank&#8221; WordPress theme for myself, because I make a lot of WordPress themes. Starting from Kubrick, or any other pre-made theme, would be absurd. There is to much stuff there that would to be stripped out or fought against to be useful. So, I have my own. It&#8217;s been in a folder called BLANK-theme on my computer for a while, so I&#8217;m going to call it BLANK. And now I&#8217;m making it available for you. Read on to find out the scoop on it and you can decide if it would be of any use to you.</p>
<p><strong>UPDATE:</strong> Please take a look at the <a href="http://html5reset.org/#wordpress">WordPress Theme that is a part of the HTML5 Reset</a>. It is based on this and far more up-to-date with modern standards. Ultimately I&#8217;ll be replacing the theme here with that.</p>
<p><span id="more-981"></span></p>
<h3>What is BLANK?</h3>
<p>It is a WordPress theme with all the functionality of a typical WordPress theme but almost none of the styling. The idea is that when starting a new theme, it is far easier to use this as a base then a theme that is already finished and styled.</p>
<h3>What are some of it&#8217;s &#8220;features&#8221;?</h3>
<ul>
<li>Things are as semantically marked up as can be for a starter theme.</li>
<li>It&#8217;s XHTML 1.0 STRICT and validates. Maybe it will go HTML5 soon. We&#8217;re at that point where there isn&#8217;t a whole ton of advantages to going to HTML5 yet, but there aren&#8217;t many downsides either and it&#8217;s definitely the future.</li>
<li>The sidebar is widget-ready.</li>
<li>Page titles are optimized for best SEO and readability/usability.</li>
<li>Functions.php file does a number of things:  Sets up RSS &lt;link>&#8217;s in the head automatically, loads jQuery, removes the weird header links like rsd_link, wlw manifest, and generator info that I&#8217;ve never once needed, and registers the sidebar widget area.</li>
<li>Has some starter CSS ready to go, more about that below.</li>
<p>Uses <code>includes</code> for some key things, like under-title meta data and forward/back navigation, that are very common places for redundant code in themes.
</ul>
<h3>About the CSS</h3>
<p>As you can see from the screenshot above, the CSS is pretty barren, but not entirely! Here are some things the CSS is set up for:</p>
<ul>
<li>Uses a basic star-selector reset.</li>
<li>Includes a .group selector for the new clearfix</li>
<li>Has basic toolbox and WordPress-standard CSS classes, including .screen-reader-text for hiding things.</li>
<li>Standard typography-related sectors are there but generally without any attributes.</li>
<li>CSS for threaded comments is in there, but light on actual styling.</li>
<li>Both screen and print styles included in single stylesheet. Print styles optimized for generic nice printing.</li>
</ul>
<h3>Demo and Download</h3>
<p><img src="http://digwp.com/wp-content/blog-images/blank-theme-example.jpg" width="590" height="475" alt="" title="" /></p>
<p>If you want to take a peek at it live, you can <a href="http://themeclubhouse.digwp.com/index.php?wptheme=BLANK%20Theme">view it in our Theme Playground</a>. You can also download it from there, or <a href="http://themeclubhouse.digwp.com/themes/BLANK/BLANK-Theme-v1.zip">directly right here</a>. </p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/02/blank-wordpress-theme/">Permalink</a> | <a href="http://digwp.com/2010/02/blank-wordpress-theme/#comments">58 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/02/blank-wordpress-theme/&title=BLANK WordPress Theme">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/css/" rel="tag">CSS</a>, <a href="http://digwp.com/tag/free/" rel="tag">free</a>, <a href="http://digwp.com/tag/theme/" rel="tag">Theme</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/02/blank-wordpress-theme/feed/</wfw:commentRss>
		<slash:comments>58</slash:comments>
		</item>
		<item>
		<title>Custom CSS Per Post</title>
		<link>http://digwp.com/2010/02/custom-css-per-post/</link>
		<comments>http://digwp.com/2010/02/custom-css-per-post/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 20:17:20 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[header]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1221</guid>
		<description><![CDATA[I&#8217;ve long been a fan of &#8220;art directing&#8221; posts. That is, to apply unique CSS styling to an individual page of content when the situation calls for it. In the past, I&#8217;ve used the Art Direction plugin and I even created a screencast on using it. As it turns out, there is a major problem [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve long been a fan of &#8220;art directing&#8221; posts. That is, to apply unique CSS styling to an individual page of content when the situation calls for it. In the past, I&#8217;ve used the <a href="http://wordpress.org/extend/plugins/art-direction/">Art Direction plugin</a> and I even <a href="http://css-tricks.com/video-screencasts/77-styling-an-individual-article/">created a screencast</a> on using it. </p>
<p>As it turns out, there is a <strong>major problem</strong> with the art direction plugin. Using it with <em>any caching plugin</em> will result in a crazy epic meltdown of your site. Without too much gory detail, in trying to cache my blog <a href="http://css-tricks.com">CSS-Tricks</a>, I tried all the major caching plugins (DB Cache, WP Super Cache, W3 Total Cache) and ultimately it would trash my WordPress database and serve up white pages. Very not good. The happy ending is that Frederick Townes from <a href="http://www.w3-edge.com/">W3 Edge</a> and creator of the W3 Total Cache plugin helped me out by patching the art direction plugin and getting CSS-Tricks cached with <a href="http://wordpress.org/extend/plugins/w3-total-cache/">W3 Total Cache</a>. I would love to release the updated code, but it&#8217;s not my code to release. We managed to get in touch with the <a href="http://noel.io/">original author</a>, who said he planed to eventually update it but didn&#8217;t sound too particularly interested in the patch.</p>
<p>SO, with that extensive backstory, what is a poor fellow to do if they want to apply custom CSS to pages TODAY? Couple ideas, read on.</p>
<p><span id="more-1221"></span></p>
<h3>style-XXXX.css</h3>
<p>One of my <a href="http://digwp.com/2010/01/wordpress-wishes/">&#8220;WordPress Wishes&#8221;</a> was that you could drop an appropriately named CSS file into a theme and it would recognize it and apply itself to the proper post. For example, /art-direction/style-XXXX.css, where XXXX is the ID of the post.</p>
<p>Reader <a href="http://tween.ir/blog/">Hassan</a> <a href="http://digwp.com/2010/01/wordpress-wishes/#comment-3072">commented</a> with a cool idea for the functions.php file:</p>
<pre><code>function artStyle() {
    global $post;
    if (is_single()) {
        $currentID = $post-&gt;ID;
        $serverfilepath = TEMPLATEPATH.'/art-direction/style-'.$currentID.'.css';
        $publicfilepath = get_bloginfo('template_url');
        $publicfilepath .= '/art-direction/style-'.$currentID.'.css';
        if (file_exists($serverfilepath)) {
            echo "&lt;link rel='stylesheet' type='text/css' href='$publicfilepath' media='screen' /&gt;"."\n";
        }
    }
}
add_action('wp_head', 'artStyle');</code></pre>
<p>I tested it out and it works great. To use it, simply create a new folder called &#8220;art-direction&#8221; in your theme. Then to style any particular Post or Page, just drop a file in that folder named style-XXXX.css where XXXX is the ID of the Post or Page. When that Post or Page loads, WordPress will look for a file of that name. If it exists, it will load in in the head section. </p>
<h3>Custom Panel</h3>
<p>Reader <a href="http://www.kerricklong.com/">Kerrick Long</a> <a href="http://digwp.com/2010/01/wordpress-wishes/#comment-3035">commented</a> another cool solution. Similar to the Art Direction plugin, this adds an input area below the main content writing area. For the functions.php file:</p>
<pre><code>//Custom CSS Widget
add_action('admin_menu', 'custom_css_hooks');
add_action('save_post', 'save_custom_css');
add_action('wp_head','insert_custom_css');
function custom_css_hooks() {
	add_meta_box('custom_css', 'Custom CSS', 'custom_css_input', 'post', 'normal', 'high');
	add_meta_box('custom_css', 'Custom CSS', 'custom_css_input', 'page', 'normal', 'high');
}
function custom_css_input() {
	global $post;
	echo '&lt;input type="hidden" name="custom_css_noncename" id="custom_css_noncename" value="'.wp_create_nonce('custom-css').'" /&gt;';
	echo '&lt;textarea name="custom_css" id="custom_css" rows="5" cols="30" style="width:100%;"&gt;'.get_post_meta($post-&gt;ID,'_custom_css',true).'&lt;/textarea&gt;';
}
function save_custom_css($post_id) {
	if (!wp_verify_nonce($_POST['custom_css_noncename'], 'custom-css')) return $post_id;
	if (defined('DOING_AUTOSAVE') &amp;&amp; DOING_AUTOSAVE) return $post_id;
	$custom_css = $_POST['custom_css'];
	update_post_meta($post_id, '_custom_css', $custom_css);
}
function insert_custom_css() {
	if (is_page() || is_single()) {
		if (have_posts()) : while (have_posts()) : the_post();
			echo '&lt;style type="text/css"&gt;'.get_post_meta(get_the_ID(), '_custom_css', true).'&lt;/style&gt;';
		endwhile; endif;
		rewind_posts();
	}
}</code></pre>
<div class="image-wrap">
<img src="http://digwp.com/wp-content/blog-images/csspanel.png" width="368" height="236" alt="" title="" /><br />
Custom CSS Write Panel
</div>
<p>As written, it&#8217;s more limiting than the Art Direction plugin as it is for CSS only rather than &#8220;anything&#8221; (e.g. JavaScript), although that would be a fairly trivial adjustment to what gets echoed out. The Art Direction plugin also allowed the CSS to be applied in other places the post might be output, for example, archives pages, whereas this does not. But to be honest, I never used that anyway.</p>
<h3>And so&#8230;</h3>
<p>Two pretty sweet and totally function solutions by Digging Into WordPress readers. Awesome. Huge thanks to Hassan and Kerrick! I would also love to see the Art Direction plugin updated as well, if nothing else, because I&#8217;m sure people download that plugin every single day from the plugin repository and have caching going on their blogs and end up in the same sore spot I was.</p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/02/custom-css-per-post/">Permalink</a> | <a href="http://digwp.com/2010/02/custom-css-per-post/#comments">29 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/02/custom-css-per-post/&title=Custom CSS Per Post">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/css/" rel="tag">CSS</a>, <a href="http://digwp.com/tag/design/" rel="tag">Design</a>, <a href="http://digwp.com/tag/functions/" rel="tag">functions</a>, <a href="http://digwp.com/tag/header/" rel="tag">header</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/02/custom-css-per-post/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>Include the Category ID via post_class</title>
		<link>http://digwp.com/2010/01/include-the-category-id-via-post_class/</link>
		<comments>http://digwp.com/2010/01/include-the-category-id-via-post_class/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 05:48:31 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[categories]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1236</guid>
		<description><![CDATA[The default output for WordPress&#8217; post_class template tag includes class names for just about every type of page view imaginable: page-parent search-results logged-in author paged Plus just about everything else except for category ID information. It gives some good category-specific class names, but nothing to represent the category ID. For example, including the post_class function [...]]]></description>
			<content:encoded><![CDATA[<p>The default output for WordPress&rsquo; <code>post_class</code> template tag includes class names for just about every type of page view imaginable:</p>
<ul>
<li>page-parent</li>
<li>search-results</li>
<li>logged-in</li>
<li>author</li>
<li>paged</li>
</ul>
<p>Plus just about everything else <em>except</em> for category ID information. It gives some good category-specific class names, but nothing to represent the category ID. For example, including the <code>post_class</code> function like this in your markup:</p>
<pre><code>&lt;div &lt;?php post_class(); ?&gt;&gt;</code></pre>
<p><span id="more-1236"></span></p>
<p>Will output something like this in your <acronym title="Hypertext Markup Language">HTML</acronym> source code:</p>
<pre><code>&lt;div class="post-5 post hentry category-uncategorized tag-demo tag-site tag-test tag-themes tag-typography"&gt;</code></pre>
<p>So if you happen to know the actual names of the categories then it&rsquo;s not really needed, but for theme development, it&rsquo;s useful to be able to generalize category distinctions and have them available as class names. Why? Because then the theme designer can apply category-specific styles very easily, and without having to mess with using actual category names.</p>
<p>For example, if we had the first category name for each post available to us as a class name, we could do something fun like this with our <acronym title="Cascading Style Sheets">CSS</acronym>:</p>
<pre><code>div[class$="0"] selector { color: red; }
div[class$="1"] selector { color: blue; }
div[class$="2"] selector { color: green; }
div[class$="3"] selector { color: brown; }
div[class$="4"] selector { color: orange; }
div[class$="5"] selector { color: yellow; }
div[class$="6"] selector { color: purple; }
div[class$="7"] selector { color: white; }
div[class$="8"] selector { color: black; }
div[class$="9"] selector { color: gold; }</code></pre>
<p>Generalized category-specific selectivity enables us to diversify and enhance our design without making any assumptions or requiring the theme user to fuss with overly complicated settings.</p>
<p>So to include each post&rsquo;s first category ID in the <code>post_class</code> output, we first need the category IDs as an array, which we can get from this tag:</p>
<p><code>get_the_category();</code></p>
<p>Then we need to pluck out the first ID from the array:</p>
<p><code>$category[0]-&gt;cat_ID;</code></p>
<p>..and then make it a function and add to your theme&rsquo;s <code>functions.php</code> file:</p>
<pre><code>// get the first category id
function get_first_category_ID() {
	$category = get_the_category();
	return $category[0]-&gt;cat_ID;
}</code></pre>
<p>Note the category IDs are sequenced numerically in the array, and that we can get at any position within the sequence by changing the &ldquo;<code>0</code>&rdquo; (which returns the <em>first</em> ID) to any number.</p>
<p>Now to include our first category ID within the output of the <code>post_class</code>, we can do something like this in our theme template files:</p>
<pre><code>&lt;div &lt;?php post_class('cat-'.get_first_category_ID()); ?&gt;&gt;</code></pre>
<p>This code will now include the category ID in the output like so:</p>
<pre><code>&lt;div class="post-5 post hentry category-uncategorized tag-demo tag-site tag-test tag-themes tag-typography cat-3"&gt;</code></pre>
<p>Notice the additional &ldquo;<code>cat-3</code>&rdquo; class name? That&rsquo;s going to correspond to the post&rsquo;s first category ID, enabling you to define category-specific design properties without dealing with category names.</p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/01/include-the-category-id-via-post_class/">Permalink</a> | <a href="http://digwp.com/2010/01/include-the-category-id-via-post_class/#comments">8 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/01/include-the-category-id-via-post_class/&title=Include the Category ID via post_class">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/categories/" rel="tag">categories</a>, <a href="http://digwp.com/tag/css/" rel="tag">CSS</a>, <a href="http://digwp.com/tag/theme/" rel="tag">Theme</a>, <a href="http://digwp.com/tag/tips/" rel="tag">tips</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/01/include-the-category-id-via-post_class/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Clean Up Empty Elements with CSS 3</title>
		<link>http://digwp.com/2009/10/clean-up-empty-elements-css3/</link>
		<comments>http://digwp.com/2009/10/clean-up-empty-elements-css3/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 13:07:38 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[XHTML]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=767</guid>
		<description><![CDATA[By default, WordPress wraps HTML comments with paragraph tags: WordPress also employs various template tags that may, in certain situations, result in empty HTML elements such as paragraphs tags: &#60;p&#62;&#60;/p&#62; &#60;p&#62;&#60;!-- --&#62;&#60;/p&#62; Other cases where empty elements are generated by WordPress involve images, line breaks, nested lists and other complex markup scenarios. Besides invalid markup, [...]]]></description>
			<content:encoded><![CDATA[<p>By default, WordPress wraps <acronym title="Hypertext Markup Language">HTML</acronym> comments with paragraph tags:</p>
<p>WordPress also employs various template tags that may, in certain situations, result in empty <acronym title="Hypertext Markup Language">HTML</acronym> elements such as paragraphs tags:</p>
<pre><code>&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;!-- --&gt;&lt;/p&gt;</code></pre>
<p>Other cases where empty elements are generated by WordPress involve images, line breaks, nested lists and other complex markup scenarios.</p>
<p><span id="more-767"></span></p>
<p>Besides invalid markup, the problem with this is that your <acronym title="Cascading Style Sheets">CSS</acronym> may be applying styles to the empty elements, potentially breaking your layout or disrupting the presentational harmony of your design.</p>
<p>For specifically targeted elements, such as paragraph elements for navigational template tags, dealing with this issue is as simple as this:</p>
<pre><code>#nav {
	display: none;
	}</code></pre>
<p>Either that or you could get all &ldquo;Google-homepage&rdquo; and use nothing but style-neutral <code>span</code>s and <code>div</code>s to markup your content. Unfortunately neither of these solutions is effective at alleviating the occasional, unpredictable WordPress-generated empty paragraph elements.</p>
<p>Fortunately, the new <code>:empty</code> pseudo-selector of <acronym title="Cascading Style Sheets">CSS</acronym>&nbsp;3 is the perfect solution for neutralizing <em>all</em> empty <acronym title="Hypertext Markup Language">HTML</acronym> elements. Here are some examples..</p>
<p>To neutralize all empty paragraphs (and only empty paragraphs), throw down the following slice of <acronym title="Cascading Style Sheets">CSS</acronym> goodness:</p>
<pre><code>p:empty {
	display: none;
	}</code></pre>
<p>Or, to cover your bases and hide <em>all</em> empty elements, add this bad boy to your stylesheet and enjoy complete satisfaction:</p>
<pre><code>*:empty {
	display: none;
	}</code></pre>
<p>In my opinion, this declaration should be included in all <acronym title="Cascading Style Sheets">CSS</acronym> reset stylesheets, but I will leave that decision up to you.</p>
<h3>But..</h3>
<p>Note that, for now, this technique only works in supportive browsers, which seems to be anything based on Mozilla. Unfortunately, Safari applies the rule to all elements of the specified element type. Hopefully this will be addressed in an upcoming version. And of course, Internet Explorer has absolutely no idea what we&rsquo;re talking about here.</p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/10/clean-up-empty-elements-css3/">Permalink</a> | <a href="http://digwp.com/2009/10/clean-up-empty-elements-css3/#comments">13 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2009/10/clean-up-empty-elements-css3/&title=Clean Up Empty Elements with CSS 3">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/css/" rel="tag">CSS</a>, <a href="http://digwp.com/tag/tips/" rel="tag">tips</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/10/clean-up-empty-elements-css3/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Advanced WordPress Targeting with body_class_plus()</title>
		<link>http://digwp.com/2009/08/wordpress-body-class-plus/</link>
		<comments>http://digwp.com/2009/08/wordpress-body-class-plus/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 03:56:30 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[body]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[tags]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=493</guid>
		<description><![CDATA[Since WordPress 2.8, we can target specific types of page views with CSS using the new body_class() tag. Designed for use within the &#60;body&#62; element, body_class() outputs various class attributes according to the current type of page view. This makes it easy to apply page-specific styling such as current-page navigation highlighting and other nifty CSS [...]]]></description>
			<content:encoded><![CDATA[<p>Since WordPress 2.8, we can target specific types of page views with <acronym title="Cascading Style Sheets">CSS</acronym> using the new <code>body_class()</code> tag. Designed for use within the <code>&lt;body&gt;</code> element, <code>body_class()</code> outputs various class attributes according to the current type of page view. This makes it easy to apply page-specific styling such as current-page navigation highlighting and other nifty <acronym title="Cascading Style Sheets">CSS</acronym> tricks.</p>
<p><span id="more-493"></span></p>
<h3>Strengths and shortcomings of the <code>body_class()</code> tag</h3>
<p>For the uninitiated, here is a quick review of the <code>body_class()</code> tag. When used as follows:</p>
<pre><code>&lt;body &lt;?php body_class(); ?&gt;&gt;</code></pre>
<p>The <code>body_class()</code> tag will output the following class names depending on current page type:</p>
<ul>
<li><code>.home</code> &#8212; class name output for the home page</li>
<li><code>.archive</code> &#8212; class name output for any archive page</li>
<li><code>.category</code> &#8212; class name output for any category page</li>
<li><code>.search</code> &#8212; class name output for any search page</li>
<li><code>.tag</code> &#8212; class name output for any tag archive page</li>
<li><a href="#attributes" title="View a complete list of body_class() attribute values">Plus many more..</a></li>
</ul>
<p>So, for example, when you are logged in to WordPress and viewing your blog&rsquo;s home page, the <code>body_class()</code> tag will result in something like this:</p>
<p><code>&lt;body class="home blog logged-in"&gt;</code></p>
<p>Or, if you were logged out and visiting your &ldquo;Asides&rdquo; category archive, your source code would include this:</p>
<p><code>&lt;body class="archive category category-asides"&gt;</code></p>
<p>This functionality enables you to, say, apply styles to the <code>&lt;h1&gt;</code> heading elements on all of your search pages:</p>
<pre><code>body.search h1 {
	border-bottom: 1px solid #ffff99;
	color: #ffff99;
	}</code></pre>
<p>Likewise, the class names output by the <code>body_class()</code> tag make it possible to target conditionally <em>any</em> element on <em>any</em> type of page, thereby greatly increasing the stylistic flexibility of WordPress. Yet despite its awesomeness, <code>body_class()</code> is essentially an &ldquo;all-or-nothing&rdquo; proposition. We can apply styles to <em>all</em> category pages, <em>all</em> search pages, <em>all</em> page pages, and so on. We can even use <acronym title="Cascading Style Sheets">CSS</acronym> chaining to target all category views when the user is logged in:</p>
<p><code>.home.logged-in {
	border: 100px solid red;
	}</code></p>
<p>This is powerful, yes, but what if we want to target, say, all categories that include the term &ldquo;services&rdquo; in the category slug? Sure, we could declare each of them individually, like this:</p>
<pre><code>.category-coffee-service { color: red; }
.category-brunch-services { color: red; }
.category-dinner-services { color: red; }
.category-snacks-services { color: red; }
.category-drinks-services { color: red; }
.category-inside-services { color: red; }
.category-design-services { color: red; }
.category-health-services { color: red; }
.category-services-info { color: red; }
.category-services-data { color: red; }
.category-services-cost { color: red; }</code></pre>
<p>But that&rsquo;s pretty inefficient. Plus, what if the user/client needed to create new &ldquo;services-related&rdquo; categories? Have fun explaining to them how edit the <acronym title="Cascading Style Sheets">CSS</acronym> file with the appropriate rules.</p>
<p>We could, I suppose, use <acronym title="Cascading Style Sheets">CSS</acronym>-3&rsquo;s wildcard substring-matching attribute-selector:</p>
<p><code>body[class*="services"] { color: red; }</code></p>
<p>Definitely cleaner, but there a significant number of browsers that do not support <acronym title="Cascading Style Sheets">CSS</acronym> 3, so this is less than an ideal solution. </p>
<p>A better solution would be to add pattern-matching functionality to the <code>body_class()</code> tag. After all, <code>body_class()</code> keeps track of just about every possible type of page-view available on your site. So why not filter the output of <code>body_class()</code> for any instances of &ldquo;services&rdquo; and output a specific class-attribute for all matching pages. This would allow us to target and apply styles to virtually <em>any</em> subset of page-views, including those new &ldquo;services-related&rdquo; categories for our client site. Say &ldquo;goodbye&rdquo; to manual code updating and say &ldquo;hello&rdquo; to automated advanced targeting with <code>body_class_plus()</code>.</p>
<h3>Advanced targeting with <code>body_class_plus()</code></h3>
<p>The <code>body_class_plus()</code> tag extends the functionality of <code>body_class()</code> by using <acronym title="PHP: Hypertext Preprocessor">PHP</acronym>&rsquo;s output buffering to conditionally evaluate its contents. This functionality enables us to pattern-match for specific phrases, and execute conditional operations based on the contents of <code>body_class()</code>.</p>
<p>Here is the <code>body_class_plus()</code> function that may be placed in your <code>functions.php</code> file:</p>
<p><strong>Update:</strong> There is a new &amp; improved version of this code <a href="#downloads" title="Download the latest version of this code">available via plugin</a>!</p>
<pre><code>&lt;?php // http://digwp.com/2009/08/wordpress-body-class-plus/
function body_class_plus() { 
	if(function_exists('body_class')) { 
		ob_start(); body_class(); 
		$class = ob_get_contents(); 
		ob_end_clean(); 
		if($class) {
			if(preg_match("/services/i", $class)) { 
				echo 'class="services"';
			} elseif(preg_match("/products/i", $class)) {
				echo 'class="products"';
			} elseif(preg_match("/business/i", $class)) {
				echo 'class="business"';
			} elseif(preg_match("/pleasure/i", $class)) {
				echo 'class="pleasure"';
			} else {
				echo 'class="no-body-class-matches"';
			}
		} else { 
			echo 'class="body-class-not-available"'; 
		} 
	}
} ?&gt;</code></pre>
<p>To call this function in your theme template, include the following tag in the element of your choice (e.g., within the <code>&lt;body&gt;</code> element):</p>
<pre><code>&lt;?php if(function_exists('body_class_plus')) { body_class_plus(); } ?&gt;</code></pre>
<p>This is a exemplified version of the <code>body_class_plus()</code> function that enables us to target and apply specific class attributes to any page or category containing the following terms in the <acronym title="Uniform Resource Locator">URL</acronym>/page-slug:</p>
<ul>
<li>&ldquo;<code>services</code>&rdquo; &#8212; will apply <code>class="services"</code></li>
<li>&ldquo;<code>products</code>&rdquo; &#8212; will apply <code>class="products"</code></li>
<li>&ldquo;<code>business</code>&rdquo; &#8212; will apply <code>class="business"</code></li>
<li>&ldquo;<code>pleasure</code>&rdquo; &#8212; will apply <code>class="pleasure"</code></li>
</ul>
<p>This makes it easy to match specific groups of categories, pages, posts, or any combination thereof. Even better, the <code>body_class_plus()</code> function makes it possible to do more than apply classes to targeted page types. In addition to, or instead of, applying classes to specific groups of pages, you can implement any type of functionality desired. For example, you could display template tags, echo content, or execute custom scripts depending on page type. The possibilities are endless.</p>
<h3 id="downloads">Download the plugin</h3>
<p>If custom functions aren&rsquo;t your thang, and you would rather implement this functionality via plugin, you can grab it here: </p>
<ul>
<li><a href="http://digwp.com/plugins/body-class-plus_v02.zip" title="Version 0.2 (latest version)">body-class-plus_v02.zip</a> (latest version)</li>
<li><a href="http://digwp.com/plugins/body-class-plus_v01.zip" title="Version 0.1 (original release)">body-class-plus_v01.zip</a> (original release)</li>
</ul>
<p>Thanks to <a href="http://kahi.cz/wordpress/" title="Kahi's WordPress Notes">Peter Kahoun</a> for contributing his expertise and improving the functionality of this plugin.</p>
<h3>Take-home message</h3>
<p>The take-home message is that the <code>body_class_plus()</code> function extends the functionality of the <code>body_class()</code> tag to target and apply styles to any particular subset or combination of page types. Further, the <code>body_class_plus()</code> function takes <code>body_class()</code> beyond the realm of <acronym title="Cascading Style Sheets">CSS</acronym>, making it possible to apply template tags, <acronym title="PHP: Hypertext Preprocessor">PHP</acronym>, and other scripts to virtually any custom-defined set of pages and page types.</p>
<h3 id="attributes">Complete list of body_class() attribute values</h3>
<p>Here is a complete list of the available classes for the <code>body_class()</code> tag:</p>
<ul>
<li>rtl</li>
<li>home</li>
<li>blog</li>
<li>archive</li>
<li>date</li>
<li>search</li>
<li>paged</li>
<li>attachment</li>
<li>error404</li>
<li>single postid-(id)</li>
<li>attachmentid-(id)</li>
<li>attachment-(mime-type)</li>
<li>author</li>
<li>author-(user_nicename)</li>
<li>category</li>
<li>category-(slug)</li>
<li>tag</li>
<li>tag-(slug)</li>
<li>page-parent</li>
<li>page-child parent-pageid-(id)</li>
<li>page-template page-template-(template file name)</li>
<li>search-results</li>
<li>search-no-results</li>
<li>logged-in</li>
<li>paged-(page number)</li>
<li>single-paged-(page number)</li>
<li>page-paged-(page number)</li>
<li>category-paged-(page number)</li>
<li>tag-paged-(page number)</li>
<li>date-paged-(page number)</li>
<li>author-paged-(page number)</li>
<li>search-paged-(page number)</li>
</ul>
<p>For more ways to dynamically set body IDs, check out my article, <a href="http://perishablepress.com/press/2009/05/26/dynamic-body-class-id-php-wordpress/" title="9 Ways to Set Dynamic Body IDs via PHP and WordPress">9 Ways to Set Dynamic Body IDs via PHP and WordPress</a>.</p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/08/wordpress-body-class-plus/">Permalink</a> | <a href="http://digwp.com/2009/08/wordpress-body-class-plus/#comments">16 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2009/08/wordpress-body-class-plus/&title=Advanced WordPress Targeting with body_class_plus()">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/body/" rel="tag">body</a>, <a href="http://digwp.com/tag/css/" rel="tag">CSS</a>, <a href="http://digwp.com/tag/functions/" rel="tag">functions</a>, <a href="http://digwp.com/tag/php/" rel="tag">PHP</a>, <a href="http://digwp.com/tag/plugin/" rel="tag">plugin</a>, <a href="http://digwp.com/tag/tags/" rel="tag">tags</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/08/wordpress-body-class-plus/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Free HTML 5 WordPress Theme</title>
		<link>http://digwp.com/2009/07/free-html-5-wordpress-theme/</link>
		<comments>http://digwp.com/2009/07/free-html-5-wordpress-theme/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 07:19:43 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Theme]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://diggingintowordpress.com/?p=215</guid>
		<description><![CDATA[In an effort to inspire more WordPress theme designers to embrace HTML 5, I am releasing the &#8220;H5&#8221; Theme Template. The H5 Theme Template is a bare-bones WordPress theme built entirely with HTML 5 and styled with CSS 2.1. As you may know, HTML 5 provides greater flexibility and interoperability than previous markup languages, and [...]]]></description>
			<content:encoded><![CDATA[<p>In an effort to inspire more WordPress theme designers to embrace <acronym title="Hypertext Markup Language">HTML</acronym> 5, I am releasing the &ldquo;<acronym title="HTML 5">H5</acronym>&rdquo; Theme Template. The <acronym title="HTML 5">H5</acronym> Theme Template is a bare-bones WordPress theme built entirely with <acronym title="Hypertext Markup Language">HTML</acronym> 5 and styled with <acronym title="Cascading Style Sheets">CSS</acronym> 2.1. As you may know, <acronym title="Hypertext Markup Language">HTML</acronym> 5 provides greater flexibility and interoperability than previous markup languages, and enables us to build well-structured themes that are more flexible, interactive, and semantically precise.</p>
<p><span id="more-215"></span></p>
<h3>About the &lsquo;H5&rsquo; WordPress Theme Template</h3>
<p>The <acronym title="HTML 5">H5</acronym> Theme Template provides everything you need to create beautiful themes with <acronym title="Hypertext Markup Language">HTML</acronym> 5 <em>right now</em>. <acronym title="HTML 5">H5</acronym> contains a complete set of theme files and folders, and each file has been meticulously crafted with all of the latest and greatest WordPress functionality. As a template theme, <acronym title="HTML 5">H5</acronym> is designed with easy customization and personalization in mind, serving as a solid starting point for your next <acronym title="Hypertext Markup Language">HTML</acronym>-5-based theme.</p>
<p>Unlike other frameworks, <acronym title="HTML 5">H5</acronym> works great as a basic theme right out of the box. Of course, this is a <em>template</em> theme we&rsquo;re talking about here, so you will inevitably feel &ldquo;inspired&rdquo; to begin tweaking and styling its minimalistic appearance to get the design looking exactly how you want it. And that is entirely the point: <acronym title="HTML 5">H5</acronym> makes it quick and easy to begin designing themes with <acronym title="Hypertext Markup Language">HTML</acronym> 5. And best of all, <acronym title="HTML 5">H5</acronym> is completely <em>free</em>. Sound good? Great, let&rsquo;s dig into the specifics..</p>
<h3>&lsquo;H5&rsquo; Specifications</h3>
<p>First, thanks for your interest in the <acronym title="HTML 5">H5</acronym> Theme Template. I am very excited to be sharing this theme with the WordPress community and hope that you will put it to good use. Next, three important points that I would like to emphasize:</p>
<ul>
<li><acronym title="HTML 5">H5</acronym> is completely free and licensed under <a href="http://www.opensource.org/licenses/gpl-3.0.html" title="GNU General Public License version 3 (GPLv3)<br />
">GPL</a></li>
<li><acronym title="HTML 5">H5</acronym> is a <strong>template</strong> used to build <acronym title="Hypertext Markup Language">HTML</acronym>-5 themes</li>
<li><acronym title="HTML 5">H5</acronym> is built entirely with WordPress, <acronym title="Hypertext Markup Language">HTML</acronym> 5, and <acronym title="Cascading Style Sheets">CSS</acronym> 2.1</li>
</ul>
<p><strong>About the markup</strong></p>
<ul>
<li>Uses as few tags and attributes as possible</li>
<li>Contains no <code>&lt;div&gt;</code>s, <code>&lt;span&gt;</code>s, <code>class</code>es, or <code>id</code>s!</li>
<li>Built with semantically sound and fully valid <acronym title="Hypertext Markup Language">HTML</acronym> 5</li>
<li>Outputs clean, well-formatted source-code (although WordPress botches most of it)</li>
</ul>
<p><strong>About the CSS</strong></p>
<ul>
<li>Just enough <acronym title="Cascading Style Sheets">CSS</acronym> to target key elements, provide some structure, and make it &ldquo;look&rdquo; like a basic theme</li>
<li>Built with well-formatted and fully valid <acronym title="Cascading Style Sheets">CSS</acronym> 2.1 (current spec)</li>
<li>Uses child, adjacent, and attribute selectors to target elements without <code>id</code>s or <code>class</code>es</li>
</ul>
<p><strong>About the JavaScript</strong></p>
<ul>
<li>Uses only unobtrusive JavaScript</li>
<li>Uses <code>createElement()</code> to specify block elements for Internet Explorer</li>
<li>Includes WordPress&rsquo; jQuery script <a href="http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/" title="Including jQuery in WordPress (The Right Way)">the right way</a></li>
</ul>
<p><strong>About the design</strong></p>
<ul>
<li>Includes minimal markup and styles for easy customization</li>
<li>Features a full set of theme template files and common folders</li>
<li>Very minimal, meant to do just the basics and serve as a starting point</li>
<li>Uses default and/or standard WordPress template tags, loops, and other functions</li>
<li>Looks and works great out of the box in (almost) all modern browsers (see next section)</li>
<li>Designed to be as lightweight and fast as possible &#8212; only essential tags are included</li>
</ul>
<p><strong>Browser compatibility</strong></p>
<p><acronym title="HTML 5">H5</acronym> looks and works great in the following browsers (and most likely others as well):</p>
<ul>
<li>Firefox 3</li>
<li>Opera 8*</li>
<li>Opera 9</li>
<li>Chrome 1 &amp; 2</li>
<li>Safari 2, 3, &amp; 4</li>
<li>Internet Explorer 7*</li>
<li>Internet Explorer 8</li>
</ul>
<p><small>* Denotes slight inconsistencies in these browsers.</small></p>
<p>For Firefox 2, Camino 1.6, and <acronym title="Internet Exploder">IE</acronym> 6, the <acronym title="Hypertext Markup Language">HTML</acronym> seems to work great, it&rsquo;s just some of the &ldquo;advanced&rdquo; <acronym title="Cascading Style Sheets">CSS</acronym> selectors that some browsers don&rsquo;t understand. <strong>This is easily handled by simply adding a few choice <code>id</code> or <code>class</code> attributes</strong> to key elements (none are used by default).</p>
<h3>Download and Demo</h3>
<p>For a &ldquo;live&rdquo; demo of the <acronym title="HTML 5">H5</acronym> Template Theme, check out our newly revamped <a href="http://themeplayground.digwp.com/index.php?wptheme=H5%20Theme%20Template" title="Launch the H5 Demo Theme">DiW Theme Playground</a>, where we will be hosting any themes that we release here at Digging into WordPress.</p>
<p>At the DiW Theme Playground you will find a dropdown menu at the top of the browser window that enables you to preview any of our themes, as well as a download link for whichever theme happens to be active (Chris&rsquo; excellent <a href="http://digwp.com/2009/06/free-theme-wp-typo/" title="Free Theme: WP Typo ">WP Typo</a> is the default active theme).</p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/07/free-html-5-wordpress-theme/">Permalink</a> | <a href="http://digwp.com/2009/07/free-html-5-wordpress-theme/#comments">40 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2009/07/free-html-5-wordpress-theme/&title=Free HTML 5 WordPress Theme">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/css/" rel="tag">CSS</a>, <a href="http://digwp.com/tag/free/" rel="tag">free</a>, <a href="http://digwp.com/tag/html/" rel="tag">HTML</a>, <a href="http://digwp.com/tag/template/" rel="tag">template</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/07/free-html-5-wordpress-theme/feed/</wfw:commentRss>
		<slash:comments>40</slash:comments>
		</item>
		<item>
		<title>Unique Body ID&#8217;s for your Pages</title>
		<link>http://digwp.com/2009/05/unique-body-ids-for-your-pages/</link>
		<comments>http://digwp.com/2009/05/unique-body-ids-for-your-pages/#comments</comments>
		<pubDate>Sat, 30 May 2009 16:46:51 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[body]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[permalink]]></category>

		<guid isPermaLink="false">http://modernwordpress.com/?p=18</guid>
		<description><![CDATA[There are many reasons you might want to get a unique ID for your tag. Let&#8217;s say you want your header elements to be a different color on your About page, you could style: h3 { color: blue; } body#about h3 { color: red; } But how do you get that ID on the About [...]]]></description>
			<content:encoded><![CDATA[<p>There are many reasons you might want to get a unique ID for your <tt><body></tt> tag. Let&#8217;s say you want your header elements to be a different color on your About page, you could style:</p>
<pre><code>h3 { color: blue; }
body#about h3 { color: red; }</code></pre>
<p>But how do you get that ID on the About page, but not on any other page? If you have your permalinks set up to show the page name, like <code>http://yoursite.com/about/</code>, you can use PHP to extract the &#8220;about&#8221; part of that URL.</p>
<p>Here is the magic:</p>
<pre><code>&lt;?php
	$url = explode('/',$_SERVER['REQUEST_URI']);
	$dir = $url[1] ? $url[1] : 'home';
?&gt;

&lt;body id="&lt;?php echo $dir ?&gt;"&gt;</code></pre>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/05/unique-body-ids-for-your-pages/">Permalink</a> | <a href="http://digwp.com/2009/05/unique-body-ids-for-your-pages/#comments">5 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2009/05/unique-body-ids-for-your-pages/&title=Unique Body ID&#8217;s for your Pages">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/body/" rel="tag">body</a>, <a href="http://digwp.com/tag/css/" rel="tag">CSS</a>, <a href="http://digwp.com/tag/header/" rel="tag">header</a>, <a href="http://digwp.com/tag/permalink/" rel="tag">permalink</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/05/unique-body-ids-for-your-pages/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

