<?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>farfromfearless &#187; How To</title>
	<atom:link href="http://www.farfromfearless.com/category/how-to/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.farfromfearless.com</link>
	<description>Personal blog of Chris Murphy</description>
	<lastBuildDate>Thu, 23 Sep 2010 01:55:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Enhancing The Previous &amp; Next Links in WordPress 3.0</title>
		<link>http://www.farfromfearless.com/2010/09/22/enhancing-the-previous-next-links-in-wordpress-3-0/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=enhancing-the-previous-next-links-in-wordpress-3-0</link>
		<comments>http://www.farfromfearless.com/2010/09/22/enhancing-the-previous-next-links-in-wordpress-3-0/#comments</comments>
		<pubDate>Wed, 22 Sep 2010 14:00:46 +0000</pubDate>
		<dc:creator>Chris Murphy</dc:creator>
				<category><![CDATA[Developement]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Themes]]></category>
		<category><![CDATA[current post]]></category>
		<category><![CDATA[get_adjacent_post]]></category>
		<category><![CDATA[next post]]></category>
		<category><![CDATA[previous post]]></category>

		<guid isPermaLink="false">http://www.farfromfearless.com/?p=598</guid>
		<description><![CDATA[The “previous post” and “next post” links that appear in your WordPress templates can be quite handy when navigating between posts, but for the most part the output of get_next_post_link() and get_previous_post_link() are quite limited.]]></description>
			<content:encoded><![CDATA[<p>Instead of going through all of the hassle to hack out new functionality to support an existing feature, we can rely on existing functionality within WordPress’ core to extend the feature. In this case, we can take advantage of WordPress’ underrated <em>get_adjacent_post()</em> function, which you can find in the link-template.php</p>
<p><a href="http://www.farfromfearless.com/wp-content/uploads/2010/09/prev_next_post_lg.jpg"><img class="alignnone size-full wp-image-622" title="prev_next_post_lg" src="http://www.farfromfearless.com/wp-content/uploads/2010/09/prev_next_post_lg-e1285206822122.jpg" alt="Example of the featre enhancement in action." width="540" height="362" /></a></p>
<p><em><strong>Fig. 1</strong> The image above is an example of the feature enhancement in action.</em></p>
<h2>WordPress’ get_adjacent_post() Function</h2>
<p>The function, <em>get_adjacent_post()</em> has been around since WordPress 2.5, but despite it’s availability, I’ve seen a number of hacks that come in the form of bloated plug-in files and unnecessary SQL Queries (using WP_Query).</p>
<p>With all of the great upgrades that WordPress has received with the 3.0   release, it&#8217;s too bad that some of the core features didn&#8217;t receive   additional treatment&#8211;but then again, I suppose that an update to a  function like <em>get_adjacent_post()</em> wouldn&#8217;t make much sense and would likely break  backwards functionality (and not to mention that WordPress is intended  to be extensible.)</p>
<p>With that in mind, let&#8217;s take a look at how we can extend a core feature like <em>get_adjacent_post()</em>.</p>
<h2>The getPostNavigation() Function</h2>
<p>Using <em>get_adjacent_post()</em> we are able to retrieve the previous and next post easily, but the real benefit comes in the fact that we’re retrieving all of the data associated with that post: Post Title, Post Content, Post Excerpt, Post Permalink, etc.</p>
<p><strong>Note:</strong> There exists two other function calls that go unnoticed by the majority of theme developers: <em>get_previous_post()</em>, and <em>get_next_post()</em>. Both of these utility functions use <em>get_adjacent_post()</em>, but these are really just vanity methods for <em>get_adjacent_post()</em>&#8211;we want to go straight to the original method.</p>
<h3>Goals of this function:</h3>
<ol>
<li>Get the Previous, Next, and Current Post with one function call</li>
<li>Get a well-formatted unordered list</li>
<li>Extensibility</li>
</ol>
<pre class="brush: php;">
/**
 * Get either the current, previous or next post in an unordered list structure.
 * @param String $post_position The post position: &quot;previous&quot; = previous post, &quot;next&quot; = next post, &quot;current&quot; = current post.
 * @param Bool $showpermalink Show or hide the permalink in the post title (typically used only for the previous and next posts)
 * @param Array $classes An array of classes to be applied to the unordered list
 * @return string The previous or next post formatted in an unordered list that can be styled
 */
 function getPostNavigation( $post_position = 'previous', $showpermalink = false, $classes = array() )
 {
 try
 {
 $objPost;
 $classes[] = 'post-navi';
 switch( $post_position )
 {
 case 'next' :
 $objPost = get_adjacent_post( false, '', false );
 $classes[] = 'next-post';
 break;
 case 'current' :
 global $post;
 $objPost = $post;
 $classes[] = 'current-post';
 break;
 case 'previous' :
 default:
 $objPost = get_adjacent_post( false, '',true );
 $classes[] = 'prev-post';
 break;
 }

 if( empty( $objPost ) ) return;

 // The title with additional formatting applied
 // TODO: Apply your own formatting, truncation, etc.
$title        = htmlentities( $title );

 // An HTML safe string to be used with the tooltip
 $tooltip    = ( $post_position != 'current' ) ? &quot;View Post: &amp;quot;&quot; . $title . &quot;&amp;quot;&quot; : &quot;&amp;quot;&quot; . $title . &quot;&amp;quot;&quot;;

 // Standard elements, heading, permalink, and excerpt
 $heading    = ( $post_position != 'current' ) ? '&lt;a href=&quot;' . get_permalink( $objPost-&gt;ID ) . '&quot; title=&quot;' . $tooltip . '&quot;&gt;' . $title . '&lt;/a&gt;' : $title;
 $permalink    = '&lt;a href=&quot;' . get_permalink( $objPost-&gt;ID ) . '&quot; title=&quot;' . $tooltip . '&quot;&gt;Read More&lt;/a&gt;';
 $excerpt     = trim( strip_tags( $objPost-&gt;post_content ) ) ;

 // The formatted output
 $output     = &quot;&lt;ul class=\&quot;&quot; . implode(' ', $classes) . &quot;\&quot;&gt;\r\n&quot;;
 $output    .= &quot;&lt;li class=\&quot;post-navi-heading\&quot;&gt;{$heading}&lt;/li&gt;\r\n&quot;;
 $output    .= &quot;&lt;li class=\&quot;post-navi-excerpt\&quot;&gt;{$excerpt}&lt;/li&gt;\r\n&quot;;
 $output    .= ( $showpermalink == true ) ? &quot;&lt;li class=\&quot;post-navi-permalink\&quot;&gt;{$permalink}&lt;/li&gt;\r\n&quot; : '';
 $output    .= &quot;&lt;/ul&gt;\r\n&quot;;
 }
 catch( Exception $err )
 {
 throw new Exception( $err-&gt;getMessage() );
 }

 return $output;
 }
</pre>
<h3>Example Usage</h3>
<pre class="brush: php;">
if( function_exists( getPostNavigation ) )
 {
 $prev_post_ul = getPostNavigation( 'previous', true, array( 'your-custom-class', 'another-class', 'one-more-class' ) );
 $curr_post_ul = getPostNavigation( 'current', false, array( 'link-list', 'col', 'one-col' ) );
 $next_post_ul = getPostNavigation( 'next', true, array( 'link-list', 'col', 'one-col', 'last' ) );
 }

&lt;!-- SET: POST NAVIGATION --&gt;
 &lt;div&gt;
 &lt;?php echo $prev_post_ul; ?&gt;
 &lt;?php echo $curr_post_ul; ?&gt;
 &lt;?php echo $next_post_ul; ?&gt;
 &lt;/div&gt;
 &lt;!-- END: POST NAVIGATION --&gt;
</pre>
<p>Like the get_previous_post_link() and the get_next_post_link(), we can use the function’s output wherever we want in our template, giving us the flexibility to fit the output into simple or complex layouts.</p>
<h3>The Breakdown</h3>
<pre class="brush: php;">
 $objPost;
 $classes[] = 'post-navi';
 switch( $post_position )
 {
 case 'next' :
 $objPost = get_adjacent_post( false, '', false );
 $classes[] = 'next-post';
 break;
 case 'current' :
 global $post;
 $objPost = $post;
 $classes[] = 'current-post';
 break;
 case 'previous' :
 default:
 $objPost = get_adjacent_post( false, '',true );
 $classes[] = 'prev-post';
 break;
 }
</pre>
<p>All of the magic really happens in the Switch statement. It is here that we condition the <em>get_adjacent_post()</em> function to retrieve the previous and next post&#8211;but for the current post data, we simply use the readily available <strong>$post</strong> variable.</p>
<p><strong>Note:</strong> In order to use the <strong>$post</strong> variable in any function, it’s scope must be declared using the “<em>global</em>” keyword.</p>
<p>The Switch statement is also used to add three additional CSS classes to the unordered list that can be used for custom styling if you want to use the functions&#8217; defaults. These three classes allow for distinction amongst the expected output:</p>
<ol>
<li>next-post</li>
<li>prev-post</li>
<li>current-post</li>
</ol>
<h3>The Output</h3>
<p>The output itself is pretty straight-forward: we’re slugging various fields of the previous, next, or current post into an unordered list that we can style with CSS; here is an example:</p>
<pre class="brush: php;">
$output     = &quot;&lt;ul class=\&quot;&quot; . implode(' ', $classes) . &quot;\&quot;&gt;\r\n&quot;;
 $output    .= &quot;&lt;li class=\&quot;post-navi-heading\&quot;&gt;{$heading}&lt;/li&gt;\r\n&quot;;
 $output    .= &quot;&lt;li class=\&quot;post-navi-excerpt\&quot;&gt;{$excerpt}&lt;/li&gt;\r\n&quot;;
 $output    .= ( $showpermalink == true ) ? &quot;&lt;li class=\&quot;post-navi-permalink\&quot;&gt;{$permalink}&lt;/li&gt;\r\n&quot; : '';
 $output    .= &quot;&lt;/ul&gt;\r\n&quot;;
</pre>
<h2>Extending getPostNavigation()</h2>
<p>As usual, this function will need to be placed in your <strong>functions.php</strong> file, but you shouldn’t stop there—the output can be structured however you need it. Customization for your particular needs can be accomplished by simply replacing the html markup in the function with your own.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.farfromfearless.com/2010/09/22/enhancing-the-previous-next-links-in-wordpress-3-0/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>URL Token Replacement Techniques for WordPress 3.0</title>
		<link>http://www.farfromfearless.com/2010/09/07/url-token-replacement-techniques-for-wordpress-3-0/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=url-token-replacement-techniques-for-wordpress-3-0</link>
		<comments>http://www.farfromfearless.com/2010/09/07/url-token-replacement-techniques-for-wordpress-3-0/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 01:12:27 +0000</pubDate>
		<dc:creator>Chris Murphy</dc:creator>
				<category><![CDATA[Developement]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Themes]]></category>
		<category><![CDATA[apply_filters]]></category>
		<category><![CDATA[Content Filters]]></category>
		<category><![CDATA[content_edit_pre]]></category>
		<category><![CDATA[content_save_pre]]></category>
		<category><![CDATA[get_the_content]]></category>
		<category><![CDATA[the_content]]></category>

		<guid isPermaLink="false">http://www.farfromfearless.com/?p=576</guid>
		<description><![CDATA[Automating the content migration process with WordPress as a CMS can often be a painful process, but with some simple techniques using WordPress' content filters and plug-in hooks, the process can be less cumbersome.]]></description>
			<content:encoded><![CDATA[<p>WordPress comes with many built-in features for working with Page and Post content, and in some cases WordPress’ feature sets are well suited to being used as a Content Management System (CMS) to power websites. But any good development workflow suffers from some common issues—in this case: content migration.</p>
<p>Generally speaking, if you’re using WordPress as a CMS (or any CMS really), you’re likely to have some sort of tiered development setup. Such a setup typically consists of a <strong>Development</strong>, <strong>Staging</strong>, and <strong>Production </strong>environment (servers—virtualized or otherwise), and with each of those environments will likely have a corresponding Database server like MySQL.</p>
<h2>The Issue</h2>
<p>A tiered development workflow typically requires that you promote changes in one database to another (upstream), e.g. Development to Staging to Production. In some cases the replication can be bi-directional (upstream and downstream), e.g. Production to Staging and Back to Production. This last case can be pretty rare, but it exists, and where a CMS is involved, replicating the database can be a chore unless you’ve done some serious work to automate the process.</p>
<p>Where WordPress is concerned, we run into issues when we migrate content from our Staging Server and onto our Production server.</p>
<h3>Here’s a Simple Illustration:</h3>
<p><strong>URL: http://localhost/mywordpress/</strong></p>
<pre class="brush: xml;">&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras ut risus purus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. &lt;a href=&quot;http://localhost/mywordpress/2010/09/01/the-quick-brown-fox&quot;&gt;The quick brown fox jumps over the lazy dog&lt;/a&gt;. Integer iaculis augue non lorem fermentum ac vulputate odio convallis. Curabitur congue sem vitae ipsum tempor sagittis.&lt;/p&gt;</pre>
<p><strong>URL: http://www.stagingserver.com/mywordpress/</strong></p>
<pre class="brush: xml;">&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras ut risus purus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. &lt;a href=&quot;http://localhost/mywordpress/2010/09/01/the-quick-brown-fox&quot;&gt;The quick brown fox jumps over the lazy dog&lt;/a&gt;. Integer iaculis augue non lorem fermentum ac vulputate odio convallis. Curabitur congue sem vitae ipsum tempor sagittis.&lt;/p&gt;</pre>
<p><strong>URL: http://www.productionserver.com/</strong></p>
<pre class="brush: xml;">&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras ut risus purus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. &lt;a href=&quot;http://localhost/mywordpress/2010/09/01/the-quick-brown-fox&quot;&gt;The quick brown fox jumps over the lazy dog&lt;/a&gt;. Integer iaculis augue non lorem fermentum ac vulputate odio convallis. Curabitur congue sem vitae ipsum tempor sagittis.&lt;/p&gt;</pre>
<p>Each instance of WordPress on the Development, Staging, and Production environments uses a replicated database. If you examine the links in each, you’ll see that each link is identical:</p>
<pre class="brush:xml">&lt;a href="http://localhost/mywordpress/2010/09/01/the-quick-brown-fox"&gt;…&lt;/a&gt;</pre>
<p>We’ve moved the content from one environment/database to the another, but the URIs in the content haven’t changed. That leaves us with our fundamental migration issue, and if you’ve been in such a situation, you’ll probably have taken the following approach to deal with it:</p>
<h3>Manually Updating The Database:</h3>
<p>In most cases, you’d likely run a Search &amp; Replace SQL statement that will modify all of the posts/pages/etc for you. Your Search &amp; Replace SQL might look something like this:</p>
<pre class="brush: sql;">
UPDATE wp_options SET option_value = REPLACE(option_value, &quot;localhost&quot;, &quot;www.stagingserver.com&quot;);
UPDATE wp_posts SET post_content = REPLACE(post_content, &quot;localhost&quot;, &quot;www.stagingserver.com&quot;);
UPDATE wp_posts SET post_content_filtered = REPLACE(post_content_filtered, &quot;localhost&quot;, &quot;www.stagingserver.com&quot;);
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, &quot;localhost&quot;, &quot;www.stagingserver.com&quot;);
</pre>
<p>With this approach you’d need to run this search and replace <strong>each time you migrate the database</strong> from your <em>localhost </em>to your <em>staging </em>platform.</p>
<p>What a pain.</p>
<h2>WordPress Content Filters to The Rescue</h2>
<p>To avoid all of the unnecessary hassle we need to dig a little deeper into some of the inner workings of WordPress. In this case, content filters.</p>
<p>WordPress comes with a number of built in filters that Plug-in developers can hook to enhance parts of WordPress’ core feature set. In fact, in a default setup, WordPress applies a number of filters to the content when you first save a draft; when you publish an article or page; and when you use features within the_loop().</p>
<h2>“Token” Replacement</h2>
<p>A token in the context of this article is simple a common placeholder string that can be easily referenced programmatically, and transformed/replaced with something else. As the term suggests, the “token” should be simple and easy to find in your html markup of your content.</p>
<p>The objective of this approach is to replace all of the instances of your site URL with that of a token, and do this in such a way that it is invisible to you or whomever is tasked with managing the content, e.g. set-it-and-forget-it.</p>
<p>Let’s begin.</p>
<h3>Step 1: Choosing a Token</h3>
<p>The first thing we need to do is to determine the format of our token. Here are some considerations:</p>
<ol>
<li>The token should be something that is unique in comparison to the surrounding content—meaning that if it was garbled in with html markup and other text, it would be easily recognizable.</li>
<li>The token should use only characters that are HTML safe—this excludes any special characters that might be transformed into HTML entities by WordPress’ other default content filters. There are ways to get around this, but that will be for you to discover.</li>
<li>The token that we determine should be stored as a reference in a globally accessible file, e.g. functions.php</li>
</ol>
<p>For the purposes of this article we will use the following as our token: <strong>[%URL%]</strong></p>
<h3>Step 2: The Token Replacement Functions</h3>
<pre class="brush: php;">
&lt;?php
$URL_TOKEN = '[%URL%]';
/**
* Find instances of the current domain and replace them with a token
* @param String $content - The orignal content
* @return String - The updated content with the token replacement in place of the site URL
*/
function f3_createDomainToken( $content )
{
	$domain = get_bloginfo('url');
	$token = $URL_TOKEN;

	$content = str_replace( $domain, $token, $content );

	return $content;
}

/**
* Find instances of the token and replace them with the current domain
* @param String $content - The orignal content
* @return String - The updated content with the site URL in place of the token
*/
function f3_replaceDomainToken( $content )
{
	$domain = get_bloginfo('url');
	$token = $URL_TOKEN;

	// Find instances of the token and replace them with the current domain
	$content = str_replace( $token, $domain, $content );

	return $content;
}
?&gt;
</pre>
<p>What we have with these two functions is a means to parse the content that is supplied to each one, and transform any initial references to your domains, e.g. “Site URL” into a token. Line 1 in the above code illustrates a constant that is accessible by each function and should be placed at the top of your <strong>functions.php</strong> file. The functions themselves will be to be placed in <strong>functions.php</strong> where you see fit.</p>
<h3>Step 3: The Content Filters, e.g. “Hooks”</h3>
<p>This last step is essential. In order for these functions to be of any benefit to you, they must be added to WordPress’ filter queue using the “add_filter()” method. You can use these functions independently rather than as filters, but you’ll only gain some marginal benefit, and it will require that you call the filters in your templates where you use the functions: <strong>the_content()</strong>, and <strong>get_the_content()</strong>.</p>
<p>What we want to do is ensure that when the_content() function is called in your template, the resulting output is already correctly formatted, e.g. your token has been replaced. Here are the hooks that you will need to use these functions effectively:</p>
<pre class="brush: php;">
&lt;?php
// DOMAIN REPLACEMENT FILTERS
add_filter( 'the_content',      'f3_replaceDomainToken', 11);
//add_filter( 'get_the_content',  'f3_replaceDomainToken', 11);
add_filter( 'content_edit_pre', 'f3_replaceDomainToken', 11);
add_filter( 'content_save_pre', 'f3_createDomainToken', 11);
add_filter( 'the_editor_content', 'f3_replaceDomainToken', 11);
?&gt;
</pre>
<p>The function “add_filter()” expects three parameters, two of which are required, and the last is optional. If you look at the example above, you can see that we’re using some of WordPress’ hooks:</p>
<pre class="brush: php;">
&lt;?php
the_content()
get_the_content()
content_edit_pre()
content_save_pre()
the_editor_content()
?&gt;
</pre>
<p>The first two you might already familiar with if you’ve done some template development, but the last three are ones that are primarily used by WordPress Plug-in Developers. What you probably don’t know is that all of what I’ve illustrated here can be easily wrapped into a simple WordPress plug-in. If you really consider how WordPress is built, you’ll also realize that <strong>functions.php</strong> is a very simple example of how a plug-in functions.</p>
<h4>Notes:</h4>
<ul>
<li>If you’re paying attention, you’ll notice that line 3 in the above code is commented out, this is because some plug-ins might already be applying filters to the output of get_the_content(), and you as a WordPress developer might want to do some other transformations on your content.</li>
<li>Line 6 is a rarely used (please correct me if I’m wrong) plug-in hook that’s used for plug-ins that introduce additional content fields into the normal WordPress editor.</li>
<li>You will still need to update the site url in the options  table (wp_options) when you migrate from one database/environment to another, but you  can use the first SQL statement I&#8217;ve provided in this article to handle  that.</li>
<li>Full automation of this process can be accomplished with some edits to the wp_config.php by defining a constant that will be automatically updated as you migrate from server to server; this constant will replace the reference to bloginfo(&#8216;url&#8217;) in the functions I&#8217;ve provided (I&#8217;m going to let you figure that one out).</li>
</ul>
<h2>Conclusion:</h2>
<p>Content migration is still going to be painful at times, and it doesn’t really matter if you’re using WordPress or some other setup (even your own); however, it doesn’t always have to be that way. What I’ve illustrated here is a means to mitigate some of that headache. Take some time to explore how WordPress&#8217; content filters work&#8211;you might be amazed at how much more control you actually have over your content and it&#8217;s formatting.</p>
<h3>References:</h3>
<ol>
<li>WordPress Codex: the_loop() <a title="WordPress Codex: the_loop()" href="http://codex.wordpress.org/The_Loop">explained</a></li>
<li>WordPress Codex: apply_filters() <a title="WordPress Codex: apply_filters() explained" href="http://codex.wordpress.org/Function_Reference/apply_filters">explained</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.farfromfearless.com/2010/09/07/url-token-replacement-techniques-for-wordpress-3-0/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>WordPress Theme Design Part 4: Visual Texture</title>
		<link>http://www.farfromfearless.com/2009/02/25/wordpress-theme-design-part-4-visual-texture/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=wordpress-theme-design-part-4-visual-texture</link>
		<comments>http://www.farfromfearless.com/2009/02/25/wordpress-theme-design-part-4-visual-texture/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 22:08:43 +0000</pubDate>
		<dc:creator>Chris Murphy</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Themes]]></category>
		<category><![CDATA[Grunge]]></category>
		<category><![CDATA[Industrial]]></category>
		<category><![CDATA[Textiles]]></category>
		<category><![CDATA[Textures]]></category>
		<category><![CDATA[Theme Design]]></category>
		<category><![CDATA[Watercolor]]></category>

		<guid isPermaLink="false">http://www.farfromfearless.com/?p=237</guid>
		<description><![CDATA[It’s been some time since my last posting on my “WordPress Theme Design” series (a year and change), and so I thought it was well past time that I got on with the series. In previous installments, I’ve covered topics such as layout, typography, and color &#038; contrast. This time around, I’ll be covering “texture”.]]></description>
			<content:encoded><![CDATA[<p>Visual texture plays a large role in design: the lack of and the addition of texture are all part of visual communication. It is one of the ways a designer can appeal to the users’ senses through a medium that is not tactile by nature.</p>
<p>Strategic use of texture can help to shape the perception of a design; it can turn a simple website layout into something evocative; when delivered in context with the subject matter of the site (articles, information, etc), texture can help to communicate tone and attitude.</p>
<h3>Texture In Web Design</h3>
<p>Visual textures can be lumped into three relative categories:</p>
<ol>
<li>Patterns</li>
<li>Photographic</li>
<li>Illustrated</li>
</ol>
<h4>Patterns as Texture</h4>
<p>Patterns are the most common type of texture that you encounter on the web. In many cases they are tileable images that are rendered as background images in a page, or appear as textured design accents. Patterns can range from illustrated elements that can repeat endlessly, or as three dimensional (often photographic) textures that can evoke a sense of depth and dimension.</p>
<p><strong>Example:</strong></p>
<p><a href="http://www.farfromfearless.com/wp-content/uploads/2009/02/patterns.png"><img style="display: inline" title="patterns" src="http://www.farfromfearless.com/wp-content/uploads/2009/02/patterns-thumb.png" alt="patterns" width="414" height="138" /></a></p>
<p><strong>Fig. 1</strong> – Tileable Patterns.</p>
<p><strong>Resources:</strong></p>
<ul>
<li><a title="K10K Pixel Patterns" href="http://www.k10k.net/sections/pixelpatterns/">K10K Pixel Patterns</a></li>
<li><a title="SquidFingers Patterns" href="http://www.squidfingers.com/patterns/">SquidFingers Patterns</a></li>
<li><a title="BgPatterns.com Patterns" href="http://bgpatterns.com/">BgPatterns</a></li>
</ul>
<h4>Photographs as Texture</h4>
<p>It would be more appropriate to consider photographic texture as singular instances of texture applied to the design, rather than something that is explicitly tiled as in the case of patterns. Photographic textures tend to range in subject matter, but the most common example of photographic texture are images that can be used as backgrounds, such as walls (brick, cement, etc).</p>
<p><strong>Example:</strong></p>
<p><a href="http://www.farfromfearless.com/wp-content/uploads/2009/02/b19light-fx111.jpg"><img style="display: inline" title="b19light_fx111" src="http://www.farfromfearless.com/wp-content/uploads/2009/02/b19light-fx111-thumb.jpg" alt="b19light_fx111" width="176" height="132" /></a> <a href="http://www.farfromfearless.com/wp-content/uploads/2009/02/b17dario284.jpg"><img style="display: inline" title="b17dario284" src="http://www.farfromfearless.com/wp-content/uploads/2009/02/b17dario284-thumb.jpg" alt="b17dario284" width="176" height="132" /></a> <a href="http://www.farfromfearless.com/wp-content/uploads/2009/02/47d966867f354grungetexture.png"><img style="display: inline" title="47d966867f354,Grunge-Texture" src="http://www.farfromfearless.com/wp-content/uploads/2009/02/47d966867f354grungetexture-thumb.png" alt="47d966867f354,Grunge-Texture" width="176" height="132" /></a></p>
<p><strong>Fig. 2-4 – </strong>Light, textiles and other industrial textures.</p>
<p><strong>Resources:</strong></p>
<ul>
<li><a title="ImageAfter - The Raw Base for Your Creativity" href="http://www.imageafter.com/">ImageAfter</a></li>
<li><a title="iStockPhoto: Search Royalty Free Images &amp; Photos" href="http://www.istockphoto.com/index.php">iStockPhoto</a></li>
</ul>
<h4>Illustration as Texture</h4>
<p>Illustrated texture is something of a trend over the past few years, where artists and designers mix various sources such as photographs, tileable patterns, and light to create unique textures.</p>
<p><strong>Examples:</strong></p>
<p><a href="http://www.farfromfearless.com/wp-content/uploads/2009/02/ist2-2429487greenstreakwatercolorbackground.jpg"><img style="display: inline" title="ist2_2429487-green-streak-watercolor-background" src="http://www.farfromfearless.com/wp-content/uploads/2009/02/ist2-2429487greenstreakwatercolorbackground-thumb.jpg" alt="ist2_2429487-green-streak-watercolor-background" width="176" height="139" /></a> <a href="http://www.farfromfearless.com/wp-content/uploads/2009/02/ist2-1744256bluewatercolorwash2.jpg"><img style="display: inline" title="ist2_1744256-blue-watercolor-wash-2" src="http://www.farfromfearless.com/wp-content/uploads/2009/02/ist2-1744256bluewatercolorwash2-thumb.jpg" alt="ist2_1744256-blue-watercolor-wash-2" width="176" height="106" /></a> <a href="http://www.farfromfearless.com/wp-content/uploads/2009/02/ist2-1977280yellowandorangewatercolorbackground.jpg"><img style="display: inline" title="ist2_1977280-yellow-and-orange-watercolor-background" src="http://www.farfromfearless.com/wp-content/uploads/2009/02/ist2-1977280yellowandorangewatercolorbackground-thumb.jpg" alt="ist2_1977280-yellow-and-orange-watercolor-background" width="176" height="128" /></a></p>
<p><strong>Fig. 5-7</strong> – Mixed water color backgrounds.</p>
<p><strong>Resources:</strong></p>
<ul>
<li><a title="iStockPhoto: Search Royalty Free Images &amp; Photos" href="http://www.istockphoto.com/index.php">iStockPhoto</a></li>
<li><a title="Free Photoshop Brushes at Brusheezy!" href="http://www.brusheezy.com/">Brusheezy</a></li>
</ul>
<h3>Texture in WordPress Themes</h3>
<p>Texture as a design element contributes to the overall personality of the design. When it comes to WordPress Themes, authors tend to exhibit a need to communicate an aspect of their personality through the theme they choose to employ on their blog.</p>
<p>If you’re thinking about using texture as part of your design, consider the following:</p>
<ol>
<li><strong>Theme:</strong> What is the <em>theme</em> of your theme?</li>
<li><strong>Prominence:</strong> How prominent are the textures going to be in your design?</li>
<li><strong>Repetition:</strong> How often and how many repeatable textures are you planning to use in the design?</li>
</ol>
<h3>Bringing it Together</h3>
<p>Designing a successful WordPress theme is no different from designing a compelling website layout – both need to illustrate an artistic (and practical) balance of many design concept where texture may be one fundamental aspect of that balance.</p>
<p>When you’re considering the design of your WordPress theme, think about how your chosen texture(s) will work together with your other design elements to communicate the overall theme.</p>
<p>For example, if you’re out to create a theme that needs to communicate and “outdoors lifestyle” or “nature”, you may want to consider using textures that are organic. In a case like this could could mix various types of textures (tileable, photographic and illustrated).</p>
<p><a href="http://www.farfromfearless.com/wp-content/uploads/2009/02/outdooritaliaofficialsite.png"><img style="display: inline" title="Outdoor Italia official site" src="http://www.farfromfearless.com/wp-content/uploads/2009/02/outdooritaliaofficialsite-thumb.png" alt="Outdoor Italia official site" width="540" height="369" /></a></p>
<p><strong>Fig. 8</strong> – <a title="Outdoor Italia" href="http://www.outdooritalia.it/">Outdoor Italia</a></p>
<p>The Outdoor Italia site is a great example of how various types of tileable and photographic texture can be used in a design to communicate a theme. The site makes great use of photographic textures in the form of leaves, paper, and the occasional physical item to deliver a sense of depth.</p>
<p><a href="http://www.farfromfearless.com/wp-content/uploads/2009/02/wildaboutgardening.png"><img style="display: inline" title="Wild About Gardening" src="http://www.farfromfearless.com/wp-content/uploads/2009/02/wildaboutgardening-thumb.png" alt="Wild About Gardening" width="540" height="441" /></a></p>
<p><strong>Fig. 9</strong> – <a title="Canadian Wildlife Federation - Wild About Gardening" href="http://www.wildaboutgardening.org/">Wild About Gardening</a></p>
<p>The Wild About Gardening is one of my favourite sites for two reasons: the illustration work makes subtle use of &#8212; and reference to &#8212; watercolor art, and it blends well with photographic texture. This site is a great example of Photographic and Illustrated texture working naturally together to communicate a sense of unity in the design.</p>
<p>The above examples aren’t WordPress themes, but the leap from content to editorial layout isn’t difficult to make.</p>
<p>Remember that not every WordPress design you create has to have shiny buttons and glossy blocks. Take time to experiment with texture in your design, and discover how different textures can dramatically change the tone and style of your design.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.farfromfearless.com/2009/02/25/wordpress-theme-design-part-4-visual-texture/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>How To Style Your Most Recent WordPress Posting</title>
		<link>http://www.farfromfearless.com/2008/09/06/how-to-style-your-most-recent-wordpress-posting/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=how-to-style-your-most-recent-wordpress-posting</link>
		<comments>http://www.farfromfearless.com/2008/09/06/how-to-style-your-most-recent-wordpress-posting/#comments</comments>
		<pubDate>Sun, 07 Sep 2008 02:52:55 +0000</pubDate>
		<dc:creator>Chris Murphy</dc:creator>
				<category><![CDATA[Developement]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Themes]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Techniques]]></category>
		<category><![CDATA[WordPress Posts]]></category>
		<category><![CDATA[WordPress Theme Design]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://www.farfromfearless.com/?p=167</guid>
		<description><![CDATA[One question that I'm asked most often is: "how do I get my most recent post to look different than my older posts?", and second to that is, "how do I show alternate colors in my posts?"]]></description>
			<content:encoded><![CDATA[<p>How you choose to style your blog postings is largely dependent on the theme you&#8217;ve selected to use on your blog, your writing style, as well as &#8212; perhaps &#8212; your skill at modifying the themes.</p>
<p>For the most part, you may be stuck with using the setup that the Theme Designer decided to adopt.</p>
<p>Blogs typically take one of three common approaches to displaying posts:</p>
<ol>
<li>Posts are displayed as excerpts with a &#8220;read more&#8221; link.</li>
<li>Posts are displayed with the full body of the posting.</li>
<li>Only one post is displayed with pagination available.</li>
</ol>
<p>The first approach &#8212; the most common of the three &#8212; is likely a result of the Theme Designer choosing to use the out-of-the-box functionality of the blogging software (and to be fair, it is likely the most efficient); however, not everyone wants a cookie cutter solution to displaying their posts.</p>
<p>The reality is such that you don&#8217;t actually need to do a lot of work to get your blog postings to appear the way you want them to. I can&#8217;t speak for other blogging software packages, but when it comes to WordPress, there are a many techniques you can apply to customize your postings.</p>
<h2>WordPress &#8211; The Loop</h2>
<p>The meat-and-potatoes of WordPress is &#8220;<a title="WordPress - The Loop" href="http://codex.wordpress.org/The_Loop">The Loop</a>&#8220;. If you&#8217;ve ever attempted to customize a WordPress theme, it&#8217;s likely you&#8217;ve encountered this The Loop (essentially a &#8220;while&#8221; loop). This is an example of a very simple loop (taken from the WordPress codex):</p>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   1:</span> <span style="color: #0000ff;">if</span> (have_posts()) :</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   2:</span>    <span style="color: #0000ff;">while</span> (have_posts()) :</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   3:</span>       the_post();</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   4:</span>       the_content();</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   5:</span>    endwhile;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   6:</span> endif;</pre>
</div>
</div>
<p>This is a better explanation if you&#8217;re not too familiar with code:</p>
<blockquote><p><strong>The Loop</strong> is used by WordPress to display each of your posts. Using The Loop, WordPress processes each of the posts to be displayed on the current page and formats them according to how they match specified criteria within The Loop tags.</p></blockquote>
<p>If you examine one of the template files of your theme you may encounter a more complicated version of the above snippet.  The Loop is where we are going to start to customize the appearance of your postings.</p>
<h2>Postings</h2>
<p>A post in WordPress is comprised of a number of elements such as the Title of the post, the Content of the post, and assorted information like the Date/Time, etc. In the common approaches, all of the postings share the exact same format and display identical information.</p>
<p>Boring.</p>
<p>But it doesn&#8217;t have to be this way. The developers of WordPress were smart enough to realize that while the majority of theme designers don&#8217;t mind this type of homogenous approach, there are a few Theme Designers out there who prefer not to follow this pattern. As such, WordPress is built with with the ability to modify how The Loop is applied.</p>
<p>There are several approaches to modifying The Loop, but the two that I prefer are:</p>
<ol>
<li>Use <a title="WordPress - query_posts(...)" href="http://codex.wordpress.org/Template_Tags/query_posts">query_posts</a> with counter and offset.</li>
<li>Use The Loop with counter and conditions.</li>
</ol>
<h2>The Loop With query_posts(&#8230;)</h2>
<p>It took me a while to understand what this feature did; quite simply put, it adds additional parameters in the The Loop to instruct WordPress on what to output.</p>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   1:</span> &lt;?php query_posts(<span style="color: #006080;">'showposts=1'</span>); ?&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   2:</span> &lt;?php <span style="color: #0000ff;">if</span> (have_posts()) : <span style="color: #0000ff;">while</span> (have_posts()) : the_post(); ?&gt;</pre>
</div>
</div>
<p>The snippet above was taken from <a title="Lemon Twist v2.0 Updated WordPress Theme" href="http://www.farfromfearless.com/2008/01/11/lemon-twist-v20-updated-wordpress-theme/">one of my WordPress themes</a>. In the theme, I use the above approach to display ONLY my most recent posting in full. Here&#8217;s a simplified version of the markup I use:</p>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   1:</span> &lt;!-- set main-entry --&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   2:</span> &lt;?php query_posts(<span style="color: #006080;">'showposts=1'</span>); ?&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   3:</span> &lt;?php <span style="color: #0000ff;">if</span> (have_posts()) : <span style="color: #0000ff;">while</span> (have_posts()) : the_post(); ?&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   4:</span> &lt;div <span style="color: #0000ff;">class</span>=<span style="color: #006080;">"main-entry"</span>&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   5:</span>     &lt;h2&gt;&lt;a href=<span style="color: #006080;">"&lt;?php the_permalink(); ?&gt;"</span> rel=<span style="color: #006080;">"bookmark"</span> title=<span style="color: #006080;">"Permanent Link to &lt;?php the_title(); ?&gt;"</span>&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   6:</span>     &lt;?php <span style="color: #008000;">//the post meta ?&gt;</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   7:</span>     &lt;ul <span style="color: #0000ff;">class</span>=<span style="color: #006080;">"meta-top"</span>&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   8:</span>         &lt;li&gt;&lt;strong&gt;Posted:&lt;/strong&gt; &lt;?php the_time(<span style="color: #006080;">'F j, Y'</span>); ?&gt;&lt;/li&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   9:</span>         &lt;li&gt;&lt;strong&gt;Author:&lt;/strong&gt;  &lt;?php the_author(); ?&gt;&lt;/li&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  10:</span>         &lt;li&gt;&lt;strong&gt;Filed under:&lt;/strong&gt; &lt;?php the_category(<span style="color: #006080;">','</span>); ?&gt;&lt;/li&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  11:</span>         &lt;li&gt;&lt;?php <span style="color: #0000ff;">if</span>( get_the_tags() != NULL ) { the_tags(<span style="color: #006080;">'&lt;strong&gt;Tags:&lt;/strong&gt; '</span>,<span style="color: #006080;">', '</span>); }<span style="color: #0000ff;">else</span>{ echo <span style="color: #006080;">"&lt;strong&gt;Tags:&lt;/strong&gt; No tags set for this entry."</span>; }?&gt;&lt;/li&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  12:</span>     &lt;/ul&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  13:</span>     &lt;?php</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  14:</span>         the_content(<span style="color: #006080;">'Read more...'</span>);</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  15:</span>     ?&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  16:</span> &lt;/div&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  17:</span> &lt;?php endwhile; endif; ?&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  18:</span> &lt;!-- end main-entry --&gt;</pre>
</div>
</div>
<p>In this example, The Loop is executed only once and only once. The query_posts() function passes instructions to The Loop to show only one post (using query_posts(<strong>&#8216;showposts=1&#8242;</strong>)). While The Loop is executed, it will output all of the post&#8217;s information that I&#8217;ve specified using the appropriate Post tags.</p>
<p><strong>NOTE: </strong>I have set the container &lt;div&gt; class to &#8220;main-entry&#8221;. This references a rule in my CSS file that will style the output accordingly.</p>
<p>Unfortunately, you&#8217;re stuck with only one posting on your page. We need to display older postings as well, and ideally in a format that is different than the most recent.</p>
<p>As previously mentioned, The Loop was executed only once with the example above. This is a powerful feature of query_posts(), in that you have a tremendous amount of control over The Loop &#8212; in this case, how many times it is executed.</p>
<p>To render the older postings, you can do this:</p>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   1:</span> &lt;!-- set past-entry --&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   2:</span> &lt;?php query_posts(<span style="color: #006080;">'showposts=9&amp;offset=1'</span>); ?&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   3:</span> &lt;?php <span style="color: #0000ff;">if</span> (have_posts()) : <span style="color: #0000ff;">while</span> (have_posts()) : the_post(); ?&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   4:</span> &lt;div <span style="color: #0000ff;">class</span>=<span style="color: #006080;">"past-entry"</span>&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   5:</span>     &lt;ul <span style="color: #0000ff;">class</span>=<span style="color: #006080;">"dateblock left"</span>&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   6:</span>         &lt;li <span style="color: #0000ff;">class</span>=<span style="color: #006080;">"top"</span>&gt;&lt;?php the_time(<span style="color: #006080;">'M Y'</span>); ?&gt;&lt;/li&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   7:</span>         &lt;li <span style="color: #0000ff;">class</span>=<span style="color: #006080;">"bottom"</span>&gt;&lt;?php the_time(<span style="color: #006080;">'j'</span>); ?&gt;&lt;/li&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   8:</span>     &lt;/ul&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   9:</span>     &lt;div <span style="color: #0000ff;">class</span>=<span style="color: #006080;">"entry-content"</span>&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  10:</span>         &lt;h1&gt;&lt;a href=<span style="color: #006080;">"&lt;?php the_permalink() ?&gt;"</span> rel=<span style="color: #006080;">"bookmark"</span> title=<span style="color: #006080;">"Permanent Link to &lt;?php the_title(); ?&gt;"</span>&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h1&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  11:</span>         &lt;?php</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  12:</span>             the_excerpt();</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  13:</span>         ?&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  14:</span>     &lt;/div&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  15:</span> &lt;/div&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  16:</span> &lt;?php endwhile; endif; ?&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  17:</span> &lt;!-- end past-entry --&gt;</pre>
</div>
</div>
<p>Aside from the simpler markup, the core difference between this second snippet and the first are the instructions/parameters in query_posts(), and the CSS class which is referenced.</p>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   1:</span> &lt;?php query_posts(<span style="color: #006080;">'showposts=9&amp;offset=1'</span>); ?&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   2:</span> &lt;?php <span style="color: #0000ff;">if</span> (have_posts()) : <span style="color: #0000ff;">while</span> (have_posts()) : the_post(); ?&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   3:</span> &lt;div <span style="color: #0000ff;">class</span>=<span style="color: #006080;">"past-entry"</span>&gt;</pre>
</div>
</div>
<p>If you combine both of the examples above, what you&#8217;ll find is that you&#8217;re actually running The Loop twice &#8212; in the first instance, The Loop only outputs the most recent post. In the second instance, it skips over the most recent  post completely, and outputs as many older posts as you defined in query_posts().</p>
<p><strong>NOTE:</strong> if you examine the parameters in the second query_posts() instance, you should see &#8220;<strong>showposts=9&amp;offset=1</strong>&#8221; &#8212; this will output <strong>10</strong> posts in total on your page, where <strong>9</strong> such posts are older.</p>
<h3>Styling The Posts</h3>
<p>What you need now are two CSS rules which define:</p>
<ol>
<li>&#8220;main-entry&#8221;</li>
<li>&#8220;past-entry&#8221;</li>
</ol>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   1:</span> <span style="color: #008000;">/* CSS Snippet */</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   2:</span> #post-container div.main-entry {</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   3:</span>     background-color: #CCCCCC;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   4:</span>     color: #000000;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   5:</span>     font-size: 1em;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   6:</span> }</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   7:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   8:</span> #post-container div.past-entry {</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   9:</span>     background-color: #ffffff;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  10:</span>     color:#333333;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  11:</span>     font-size: .92em;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  12:</span> }</pre>
</div>
</div>
<p>The XHTML markup does not have to be different between these posts, and as you can see in the CSS snippet above, you can get away with as little as displaying a different background color, font color or a larger font size.</p>
<h3>The Caveat</h3>
<p>Yes, there is a downside to using query_posts(). Programmatically speaking, you should try to optimize the number of queries you execute against your database. Since WordPress is largely database driven, you can expect a high volume of requests on any given page. Using query_posts() should be done sparingly (I limit it&#8217;s use to the homepage of my blog).</p>
<p>Also, if you are wanting to support pagination, you will need to do a little more work to setup the query properly &#8212; you can <a title="WordPress - query_posts()" href="http://codex.wordpress.org/Template_Tags/query_posts">read more about it here</a>.</p>
<h2>The Loop With Counter &amp; Conditions</h2>
<p>The simplest method to determine and style your most recent post in contrast to your older postings is a pure implementation of &#8220;The Loop&#8221;. This implementation also relies on using a counter to keep track of how many posts you&#8217;re outputting (as determined by your WordPress settings), as well as a condition to determine which class to reference when styling the output.</p>
<p>Here is an example of this in action:</p>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   1:</span> &lt;?php</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   2:</span>     <span style="color: #0000ff;">if</span> (have_posts()) {</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   3:</span>         <span style="color: #008000;">// the counter (initialized to 0 );</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   4:</span>         $n = 0;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   5:</span>         <span style="color: #008000;">// the while loop</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   6:</span>         <span style="color: #0000ff;">while</span> (have_posts()) {</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   7:</span>             <span style="color: #008000;">// the CSS class to apply</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   8:</span>             $<span style="color: #0000ff;">class</span> = ( $n == 0 ) ? <span style="color: #006080;">"main-entry"</span> : <span style="color: #006080;">"past-entry"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   9:</span> ?&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  10:</span>             &lt;!-- set post --&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  11:</span>             &lt;div <span style="color: #0000ff;">class</span>=<span style="color: #006080;">"&lt;?php echo $class; ?&gt;"</span>&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  12:</span>                 &lt;ul <span style="color: #0000ff;">class</span>=<span style="color: #006080;">"dateblock"</span>&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  13:</span>                     &lt;li <span style="color: #0000ff;">class</span>=<span style="color: #006080;">"top"</span>&gt;&lt;?php the_time(<span style="color: #006080;">'M Y'</span>); ?&gt;&lt;/li&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  14:</span>                     &lt;li <span style="color: #0000ff;">class</span>=<span style="color: #006080;">"bottom"</span>&gt;&lt;?php the_time(<span style="color: #006080;">'j'</span>); ?&gt;&lt;/li&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  15:</span>                 &lt;/ul&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  16:</span>                 &lt;div <span style="color: #0000ff;">class</span>=<span style="color: #006080;">"entry-content"</span>&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  17:</span>                     &lt;h1&gt;&lt;a href=<span style="color: #006080;">"&lt;?php the_permalink() ?&gt;"</span> rel=<span style="color: #006080;">"bookmark"</span> title=<span style="color: #006080;">"Permanent Link to &lt;?php the_title(); ?&gt;"</span>&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h1&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  18:</span>                     &lt;?php</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  19:</span>                         <span style="color: #0000ff;">if</span>( $n == 0 ) {</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  20:</span>                             the_content();</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  21:</span>                         }<span style="color: #0000ff;">else</span> {</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  22:</span>                             the_excerpt();</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  23:</span>                         }</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  24:</span>                     ?&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  25:</span>                 &lt;/div&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  26:</span>             &lt;/div&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  27:</span>             &lt;!-- set post --&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  28:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  29:</span> &lt;?php</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  30:</span>             <span style="color: #008000;">// incriment the counter</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  31:</span>             $n .= 1;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  32:</span>         }</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  33:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  34:</span>     }</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">  35:</span> ?&gt;</pre>
</div>
</div>
<p>As you can see from the example above, we&#8217;ve taken a basic instance of The Loop and added in two variables:</p>
<ol>
<li><strong>$n</strong> &#8212; this is the counter used to determine which which is the most recent (starting at &#8220;0&#8243; &#8212; the first).</li>
<li><strong>$class</strong> &#8212; this is the CSS class that we want to reference (&#8220;main-entry&#8221; or &#8220;past-entry&#8221;).</li>
</ol>
<p>The method and approach to styling the post is the same as the examples in query_posts(). The XHTML markup can be re-used between new and older postings, but this is not required. With a little work you can supply The Loop with two different sets of markup to render.</p>
<h3>The Caveat</h3>
<p>While this implementation is rather straight forward, it can get complicated quickly if you want to include more and more variations between postings. Each variation requires a little more forethought, and the appropriate conditions to determine what to do and what to render. What you may end up with is a lot of messy markup that is difficult to read.</p>
<h2>Conclusion</h2>
<p>It doesn&#8217;t take a lot of work to modify your WordPress template to render your most recent posting in a unique fashion. In some cases, you can download plugins to help you style your postings; for me, having to rely on additional plugins seems more overhead than is necessary. The techniques outlined in this article are only two of many such approaches (and certainly a manual approach).</p>
<p>Don&#8217;t feel as if you have to select one over the other. In fact, your writing style and your choice of template play a large part in determining which method is most appropriate.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.farfromfearless.com/2008/09/06/how-to-style-your-most-recent-wordpress-posting/feed/</wfw:commentRss>
		<slash:comments>69</slash:comments>
		</item>
		<item>
		<title>How To Quote Comments In A WordPress Comment List</title>
		<link>http://www.farfromfearless.com/2008/08/29/how-to-quote-comments-in-wordpress-comment-list/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=how-to-quote-comments-in-wordpress-comment-list</link>
		<comments>http://www.farfromfearless.com/2008/08/29/how-to-quote-comments-in-wordpress-comment-list/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 21:17:31 +0000</pubDate>
		<dc:creator>Chris Murphy</dc:creator>
				<category><![CDATA[Developement]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Themes]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Quotes]]></category>
		<category><![CDATA[WordPress Commenting]]></category>
		<category><![CDATA[WordPress Comments]]></category>

		<guid isPermaLink="false">http://www.farfromfearless.com/?p=161</guid>
		<description><![CDATA[Sometimes it's the little details that make WordPress themes really shine, other times it's the little features you can add that make working with a WordPress theme a nice experience for readers.]]></description>
			<content:encoded><![CDATA[<p>I received an email from a reader this afternoon, asking about one of the commenting features that I built into the <a title="Download Lemon Twist 2.0.x" href="http://www.farfromfearless.com/2008/01/11/lemon-twist-v20-updated-wordpress-theme/">Lemon Twist</a> theme: quote comments.</p>
<blockquote><p>Hi Chris,</p>
<p>I’m really curious on how you got that quote feature on your comment section. Do you mind sharing your code?</p>
<p>Cheers,<br />
[<span style="text-decoration: line-through;">author name omitted</span>]</p></blockquote>
<p>While this is not a new feature by and large, it is one that I thought would bring a sense of discussion to the linear WordPress comment format much like how forums work. I&#8217;ve attempted to use threaded commenting plugins, but they are ugly and overly complicated for something that should be fairly straight forward.</p>
<p>In any case, this is the JavaScript snippet that I wrote (you need <a title="jQuery" href="http://jquery.com/">jQuery</a>, but comes with the theme)</p>
<pre>// attach a function to the quote comment link
  $('a.quote-comment').click( function() {
      var tb = $('#comment');
      var strQuote = $(this).attr('title');
      // assign the value
      tb.val('&lt;blockquote&gt;' + strQuote + '&lt;/blockquote&gt;');
      return false;
   });</pre>
<p>This is the result:</p>
<p><a href="http://www.farfromfearless.com/wp-content/uploads/HowtoQuoteCommentsinWordPressCommentList_ECB9/quote.jpg"><img src="http://www.farfromfearless.com/wp-content/uploads/HowtoQuoteCommentsinWordPressCommentList_ECB9/quote_thumb.jpg" alt="quote" width="540" height="173" /></a></p>
<p>There are a couple caveats to this feature</p>
<ol>
<li>You can only quote one comment at a time, as I didn&#8217;t build in concatenation.</li>
<li>It is not parameterized so you&#8217;ll have to customize it for your own theme.</li>
<li>Requires some additional styling (no big deal).</li>
</ol>
<p>If anyone wants to improve on this, feel free to share!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.farfromfearless.com/2008/08/29/how-to-quote-comments-in-wordpress-comment-list/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

