<?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/category/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>Displaying Theme Data with WordPress</title>
		<link>http://digwp.com/2011/12/displaying-theme-data-with-wordpress/</link>
		<comments>http://digwp.com/2011/12/displaying-theme-data-with-wordpress/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 18:36:29 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=5457</guid>
		<description><![CDATA[A cool trick you can do with WordPress is display information directly from your theme&#8217;s style.css stylesheet. I recently used this on a site where the theme&#8217;s version number is used throughout the template to keep things current and consistent. get_theme_data() The function that makes it possible is called get_theme_data(), and it simply returns an [...]]]></description>
			<content:encoded><![CDATA[<p>A cool trick you can do with WordPress is display information directly from your theme&#8217;s <code>style.css</code> stylesheet. I recently used this on a site where the theme&#8217;s version number is used throughout the template to keep things current and consistent.</p>
<p><span id="more-5457"></span></p>
<h3>get_theme_data()</h3>
<p>The function that makes it possible is called <a href="http://codex.wordpress.org/Function_Reference/get_theme_data">get_theme_data()</a>, and it simply returns an array of information about any of your theme files. Here is how it&#8217;s used in your theme template:</p>
<pre><code>&lt;?php get_theme_data( $theme_filename ); ?&gt;</code></pre>
<p>So <code>$theme_filename</code> is required and should be the path and filename of your theme&#8217;s <code>style.css</code> file. There is no default value for this, so you need to ensure a proper value.</p>
<p>So what information can you display with <code>get_theme_data()</code>? The function returns an array of values that basically comprises the different meta items in your stylesheet. Here is a list of possible return values (all strings):</p>
<ul>
<li><code>Name</code> &ndash; theme name</li>
<li><code>Title</code> &ndash; either theme name or linked theme name</li>
<li><code>URI</code> &ndash; theme <abbr title="Uniform Resource Identifier">URI</abbr></li>
<li><code>Description</code> &ndash; wptexturized version of the theme name</li>
<li><code>AuthorURI</code> &ndash; theme author URI</li>
<li><code>Template</code> &ndash; theme parent template, if exists</li>
<li><code>Version</code> &ndash; theme version number</li>
<li><code>Status</code> &ndash; theme status (default: <code>publish</code>)</li>
<li><code>Tags</code> &ndash; theme tags</li>
<li><code>Author</code> &ndash; author name or linked author name</li>
</ul>
<p>Note that these return values are <strong>case-sensitive</strong> and will not work if the first letter is not capitalized.</p>
<h3>Examples</h3>
<p>The Codex provides this example for getting and displaying the theme <code>Name</code> and <code>Author</code>:</p>
<pre><code>&lt;?php

    /*
     * Assign theme folder name that you want to get information.
     * make sure theme exist in wp-content/themes/ folder.
     */

    $theme_name = 'twentyeleven'; 

   /*
    * Do not use get_stylesheet_uri() as $theme_filename,
    * it will result in PHP fopen error if allow_url_fopen is set to Off in php.ini,
    * which is what most shared hosting does. You can use get_stylesheet_directory()
    * or get_template_directory() though, because they return local paths.
    */

    $theme_data = get_theme_data( get_theme_root() . '/' . $theme_name . '/style.css' );
    echo $theme_data['Title'];
    echo $theme_data['Author'];

?&gt;</code></pre>
<p>This should get you going.. just copy/paste into your theme template and indicate the theme name in that first line of code. Displaying other bits of theme data is matter of editing/replicating those last two lines. </p>
<p>Once you see how it works, you can do cool stuff with it, like display your theme&#8217;s version number sort of globally throughout your site. I&#8217;m using this technique to append version parameters to my stylesheet <abbr title="Uniform Resource Locator">URL</abbr>s, like so:</p>
<pre><code>&lt;link rel="stylesheet" href="&lt;?php bloginfo('stylesheet_directory'); ?&gt;/style.css&lt;?php if(function_exists('theme_version')) theme_version(); ?&gt;"&gt;</code></pre>
<p>..and the output markup looks like this (notice the appended version parameter, <code>?v=1.3</code>):</p>
<pre><code>&lt;link rel="stylesheet" href="http://example.com/wp-content/themes/xycss/style.css?v=1.3"&gt;</code></pre>
<p>Because I am using multiple stylesheets, this method really saves a LOT of time trying to keep track of everything. Here is the <code>theme_version()</code> function that goes in your theme&#8217;s <code>functions.php</code> file:</p>
<pre><code>// display version number
function theme_version() {
    $theme_name = 'xycss'; // customize with your theme name
    $theme_data = get_theme_data( get_theme_root() . '/' . $theme_name . '/style.css' );
    echo '?v=' . $theme_data['Version'];
}</code></pre>
<p>And with a few modifications, you can also display your theme&#8217;s information in your posts and pages via <strong>shortcode</strong>:</p>
<pre><code>// version number shortcode
function theme_version_shortcode() {
    $theme_name = 'xycss'; // customize with your theme name
    $theme_data = get_theme_data( get_theme_root() . '/' . $theme_name . '/style.css' );
    return $theme_data['Version'];
}
add_shortcode('theme_version', 'theme_version_shortcode');</code></pre>
<p>With that second snippet in your <code>functions.php</code> file, displaying your theme info directly in pages is as easy as writing this:</p>
<p><code>[theme_version]</code></p>
<p>..and the output:</p>
<p><code>1.3</code></p>
<p>It&#8217;s pretty cool stuff, and I&#8217;m sure there&#8217;s tons more you can do with it too. If you know any tricks or tips, please share in the comments, Thanks :)</p>
<hr />
<p><small>© 2011 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2011/12/displaying-theme-data-with-wordpress/">Permalink</a> | <a href="http://digwp.com/2011/12/displaying-theme-data-with-wordpress/#comments">10 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2011/12/displaying-theme-data-with-wordpress/&title=Displaying Theme Data with WordPress">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/functions/" rel="tag">functions</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/2011/12/displaying-theme-data-with-wordpress/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Make the Visual Editor Actually WYSIWYG</title>
		<link>http://digwp.com/2010/11/actual-wysiwyg/</link>
		<comments>http://digwp.com/2010/11/actual-wysiwyg/#comments</comments>
		<pubDate>Sun, 28 Nov 2010 16:18:14 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[functions.php]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=3212</guid>
		<description><![CDATA[In otherwords, match what you see when creating/editing a Post or Page in the WordPress visual editor to what you get when you actually publish it. It&#8217;s easier than you might think! Basically you can declare a special CSS file that the visual editor will use to render itself while you are editing it. If [...]]]></description>
			<content:encoded><![CDATA[<p>In otherwords, match what you see when creating/editing a Post or Page in the WordPress visual editor to what you get when you actually publish it. It&#8217;s easier than you might think! Basically you can declare a special CSS file that the visual editor will use to render itself while you are editing it. If the styles in that CSS file match the styles in your live theme&#8217;s CSS file, you are straight up WYSIWYG (What You See Is What You Get).</p>
<p><span id="more-3212"></span></p>
<h3>1) Declare CSS for Visual Editor</h3>
<p>Very easy, one-liner in your functions.php file.</p>
<pre><code>// Add CSS to Visual Editor
add_editor_style('css/custom-editor-style.css');</code></pre>
<p>The file path that you pass as a parameter is relative to your theme&#8217;s root. Make sure to actually create this file in your theme folder, at the specified location!</p>
<h3>2) Make Sure You Have a Common Class To Work With</h3>
<p>The HTML markup for the posts on your site are very likely wrapped within a container element. Perhaps something like:</p>
<pre><code>&lt;div class="post"&gt;
  &lt;!-- all content for entire post in here --&gt;
&lt;/div&gt;</code></pre>
<p>Then your typography CSS likely uses that class name to to create typography specific to posts:</p>
<pre><code>.post h1, .post h2, .post h3, .post h4 { font-family: MuseoLight, Georgia, serif; font-weight: normal; margin: 0 0 10px 0; }
.post h2 { font-size: 28px; }
.post h2 { padding: 10px 180px 10px 15px; background: #237abf url(../images/title-bg.png) repeat-x; margin: 0; line-height: 1.3; font-size: 22px; }
.post h2, .post h2 a { color: white; text-shadow: 0 1px 2px #143855; }
.post h2 a:hover { color: #b8e0ff; }
.post h3 { font-size: 20px; padding: 5px 0; margin: 30px 0 15px 0; border-top: 1px solid #ccc; border-bottom: 1px solid #ccc; }
.post h4 { font-size: 18px; }
.post p { margin: 0 0 10px 0; }
.post pre { background: #eee; padding: 15px; overflow: auto; margin: 0 0 15px 0; border: 1px solid #ddd; }
.post pre code { font-size: 11px; }
.post code { background: #eee; font: 12px Monaco, Courier, Monospace; color: #0E304A; }
.post h3 code { font-size: 18px; }
.post acronym, abbr { border-bottom: 1px dotted #514031; cursor: help; }
.post ins { text-decoration: underline; }
.post del { text-decoration: line-through; }
.post a { outline: none; text-decoration: none; color: #19517C; background: #eee; border: 1px solid #ddd; padding: 1px 3px 2px 3px; -webkit-border-radius: 3px; -khtml-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; }
.post a:hover { color: #fff; background: #143855; border: 1px solid #143855; }</code></pre>
<p>It would be nice if we could just copy and paste that over to the CSS file we declared in Step 1. The problem is, the Visual Editor doesn&#8217;t have that same class name inside of it. So if we did a straight up copy-and-paste, none of these styles would apply. Rather than re-jigger all our CSS to not use that class name, we can actually just force the visual editor to also have that class name.</p>
<p>Just put this in functions.php:</p>
<pre><code>// Add body class to Visual Editor to match class used live
function mytheme_mce_settings( $initArray ){
 $initArray['body_class'] = 'post';
 return $initArray;
}
add_filter( 'tiny_mce_before_init', 'mytheme_mce_settings' );</code></pre>
<p>This isn&#8217;t quite as efficient as referencing a single file, but at least you can copy and paste easily. If you are the type of person who separates CSS out into different files (like Typography has it&#8217;s own typography.css), then you are more than welcome to reference the same CSS both for Visual Editor and in the live theme. That&#8217;s just now how I roll.</p>
<p>The body class trick is from <a href="http://moronicbajebus.com/">Seamus Leahy</a>. Thanks Seamus!</p>
<h3>The Result:</h3>
<p>Check out this example of this very post from back end to front end:</p>
<p><img src="http://digwp.com/wp-content/uploads/sametypography.jpg" alt="" title="sametypography" width="591" height="470" class="alignnone size-full wp-image-3408" /></p>
<p>You can literally do anything CSS can do, right down to the custom web fonts!</p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/11/actual-wysiwyg/">Permalink</a> | <a href="http://digwp.com/2010/11/actual-wysiwyg/#comments">26 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/11/actual-wysiwyg/&title=Make the Visual Editor Actually WYSIWYG">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/editor/" rel="tag">editor</a>, <a href="http://digwp.com/tag/functions-php/" rel="tag">functions.php</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/11/actual-wysiwyg/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<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>Specify Unique CSS File Per Post</title>
		<link>http://digwp.com/2010/05/specify-unique-css-file-per-post/</link>
		<comments>http://digwp.com/2010/05/specify-unique-css-file-per-post/#comments</comments>
		<pubDate>Mon, 10 May 2010 21:20:39 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=2082</guid>
		<description><![CDATA[I&#8217;m a HUGE fan of being able to link up a CSS file on a per-page basis. I just find it extremely common that a page needs CSS styling unique to it, and I hate litering a sites main stylesheet with customizations that only one particular page needs. We&#8217;ve talked about this before, and even [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a HUGE fan of being able to link up a CSS file on a per-page basis. I just find it extremely common that a page needs CSS styling unique to it, and I hate litering a sites main stylesheet with customizations that only one particular page needs. We&#8217;ve talked about this before, and even created a <a href="http://digwp.com/2010/02/custom-css-per-post/">custom method for doing so</a>, as well as mentioned the <a href="http://wordpress.org/extend/plugins/art-direction/">art direction plugin</a>, which makes this easily possible. </p>
<p>Both of those methods are still sweet, but I find in general that I like to write my CSS in actual CSS files I keep in my theme and can edit using whatever CSS editor I like, as well as keep things clean and simple in the admin. So, I&#8217;ve altered the technique a bit.</p>
<p><span id="more-2082"></span></p>
<p>The idea is to add a simple text input to the page editor, right underneath the content area, where you can manually specify the name of a CSS file. In the image below, you can see I&#8217;ve also added one for JavaScript.</p>
<p><img src="http://digwp.com/wp-content/blog-images/customfiles.png" width="590" height="177" alt="" title="" /></p>
<p>To add this to your site, it&#8217;s just some code to add to the functions.php file. Should work for any site.</p>
<pre><code>// Custom Stylesheet box in Pages/Posts
add_action('admin_menu', 'digwp_custom_css_hooks');
add_action('save_post', 'digwp_save_custom_css');
add_action('wp_head','digwp_insert_custom_css');
function digwp_custom_css_hooks() {
	add_meta_box('custom_css', 'Name of custom CSS file', 'digwp_custom_css_input', 'post', 'normal', 'high');
	add_meta_box('custom_css', 'Name of custom CSS file', 'digwp_custom_css_input', 'page', 'normal', 'high');
}
function digwp_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;input type="text" name="custom_css" id="custom_css" style="width:100%;" value="'.get_post_meta($post-&gt;ID,'_custom_css',true).'" /&gt;';
}
function digwp_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 digwp_insert_custom_css() {
	if (is_page() || is_single()) {
		if (have_posts()) : while (have_posts()) : the_post();
		  $filename = get_post_meta(get_the_ID(), '_custom_css', true);
		  if ($filename) {
			echo "&lt;link rel='stylesheet' type='text/css' href='" . get_bloginfo('template_url') . "/css/" . $filename . "' /&gt;";
          }
		endwhile; endif;
		rewind_posts();
	}
}</code></pre>
<p>If you are happy with just CSS only, you can stop there. If you would like the JavaScript box as well, here is that code.</p>
<pre><code>// Custom JavaScript in Pages/Posts  (...lots of repeated code, could be better)
add_action('admin_menu', 'digwp_custom_js_hooks');
add_action('save_post', 'digwp_save_custom_js');
add_action('wp_head','digwp_insert_custom_js');
function digwp_custom_js_hooks() {
	add_meta_box('custom_js', 'Name of custom JavaScript file', 'digwp_custom_js_input', 'post', 'normal', 'high');
	add_meta_box('custom_js', 'Name of custom JavaScript file', 'digwp_custom_js_input', 'page', 'normal', 'high');
}
function digwp_custom_js_input() {
	global $post;
	echo '&lt;input type="hidden" name="custom_js_noncename" id="custom_js_noncename" value="'.wp_create_nonce('custom-js').'" /&gt;';
	echo '&lt;input type="text" name="custom_js" id="custom_js" style="width:100%;" value="'.get_post_meta($post-&gt;ID,'_custom_js',true).'" /&gt;';
}
function digwp_save_custom_js($post_id) {
	if (!wp_verify_nonce($_POST['custom_js_noncename'], 'custom-js')) return $post_id;
	if (defined('DOING_AUTOSAVE') &amp;&amp; DOING_AUTOSAVE) return $post_id;
	$custom_js = $_POST['custom_js'];
	update_post_meta($post_id, '_custom_js', $custom_js);
}
function digwp_insert_custom_js() {
	if (is_page() || is_single()) {
		if (have_posts()) : while (have_posts()) : the_post();
		    $filename = get_post_meta(get_the_ID(), '_custom_js', true);
		    if ($filename) {
			 echo "&lt;script type='text/javascript' src='" . get_bloginfo('template_url') . "/js/" . $filename . "' &gt;&lt;/script&gt;";
            }
		endwhile; endif;
		rewind_posts();
	}
}</code></pre>
<p>You could probably combine these together a bit better than I have done here, it&#8217;s a bit redundant. </p>
<h3>How it Works</h3>
<p>There are three things going on here, which tap into three existing WordPress &#8220;hooks&#8221;.</p>
<ol>
<li>Adds text inputs to the page editing screen of the admin using the <code>admin_menu</code> hook and the <code>add_meta_box</code> function</li>
<li>Save the values of those text inputs when the page is saved using the <code>save_post</code> hook</li>
<li>Output <code>&lt;link&gt;</code> or <code>&lt;script&gt;</code> tags in the <code>&lt;head&gt;</code> of the site (when those values are present) using the <code>wp_head</code> hook.</li>
</ol>
<h3>The Result</h3>
<p>If you put the value &#8220;yeahbaby.css&#8221; in that input box, when that particular page loads, you are going to get this output in the <code>&lt;head&gt;</code>:</p>
<pre><code>&lt;link rel='stylesheet' type='text/css' href='http://yoursite.com/notes/wp-content/themes/your-theme/css/yeahbaby.css' /&gt;</code></pre>
<p>&#8220;yoursite.com&#8221; will obviously be your sites domain, and your-theme will the folder in which your currently active theme resides. Do keep that in mind, as should you change themes, you&#8217;ll need to move the &#8220;css&#8221; folder in that theme that contains these custom CSS files to the new theme. </p>
<h3>UPDATE (May 13, 2010)</h3>
<p>Notice how all the function names are prefixed by &#8220;digwp_&#8221; &#8211; that is in accordance to best practices described by Andrew Nacin <a href="http://www.andrewnacin.com/2010/05/11/in-wordpress-prefix-everything/">here</a>.</p>
<p>This has also been <a href="http://wordpress.org/extend/plugins/include-custom-files/">made into a plugin</a> by <a href="http://utkar.sh/">Utkarsh Kukreti</a>. Requires PHP5.</p>
<h3>Ways This Code Could Be Improved</h3>
<p>I was holding back on publishing this because there are a lot of ways it could be better. But I had mentioned it at the <a href="http://www.cmsexpo.net/">CMS Expo</a> and there was some interested and I said I would, so I&#8217;m releasing it a bit early. Here are things that could be better&#8230;</p>
<ul>
<li>Combine the functions together to create less redundancies between the CSS and JavaScript versions.</li>
<li>Allow for a comma-separated list in case multiple custom CSS files are needed.</li>
<li>Make it a plugin instead of custom functions. Add options screen to specify file path to custom CSS folder.</li>
</ul>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/05/specify-unique-css-file-per-post/">Permalink</a> | <a href="http://digwp.com/2010/05/specify-unique-css-file-per-post/#comments">21 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/05/specify-unique-css-file-per-post/&title=Specify Unique CSS File Per Post">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/functions/" rel="tag">functions</a>, <a href="http://digwp.com/tag/php/" rel="tag">PHP</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/05/specify-unique-css-file-per-post/feed/</wfw:commentRss>
		<slash:comments>21</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>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>
	</channel>
</rss>

