<?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>Curtis Henson &#187; Articles</title>
	<atom:link href="http://curtishenson.com/category/articles/feed/" rel="self" type="application/rss+xml" />
	<link>http://curtishenson.com</link>
	<description>Freelance Web Designer and Wordpress Guru</description>
	<lastBuildDate>Wed, 21 Jul 2010 15:53:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>WordPress Custom Post Type and Meta Boxes Example</title>
		<link>http://curtishenson.com/wordpress-custom-post-types-and-meta-boxes-example/</link>
		<comments>http://curtishenson.com/wordpress-custom-post-types-and-meta-boxes-example/#comments</comments>
		<pubDate>Sat, 01 May 2010 00:00:27 +0000</pubDate>
		<dc:creator>Curtis Henson</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://curtishenson.com/?p=920</guid>
		<description><![CDATA[WordPress 3.0 is coming soon and one of the biggest new features is the ability to add custom post types. Making these custom post types is pretty easy, here is a simple but complete example of creating a link type custom post.]]></description>
			<content:encoded><![CDATA[<p>WordPress 3.0 is coming soon and one of the biggest new features is the ability to add custom post types. Making these custom post types is pretty easy, below is a simple but complete example of creating a link type custom post.</p>
<h3>Register the Custom Post</h3>
<p>The first thing you see here is the <code>register_post_type</code> function which starts everything. You can read about this on the <a href="http://codex.wordpress.org/Function_Reference/register_post_type">codex page</a> or <a href="http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress">Justin Tadlock&#8217;s post</a>. These two pages should get you up to speed fast.</p>
<h3>Actions and Filters</h3>
<p>The next bit of code are all the callbacks. The first two deal with adding the meta box and saving it. The next two change the columns in the WordPress admin when viewing a list of the custom posts. The last is for using custom template names.</p>
<h4>The Meta Box</h4>
<p>The first two functions <code>link_url_meta_box()</code> and <code>save_post_data()</code> deal with the added meta box. I&#8217;ve kept things simple here so it should be easy to follow what&#8217;s happening.</p>
<h4>Custom Columns</h4>
<p>When looking through the list of your custom post you&#8217;ll probably want to display custom columns so it&#8217;s easier to find what you want. The <code>nav_columns</code> and <code>custom_nav_columns</code> control this: <code>nav_columns</code> sets everything up, and <code>custom_nav_columns</code> determines what will be listed there.</p>
<h4>Custom Template Names</h4>
<p>WordPress by default will use &#8220;<em>single-link.php</em>&#8221; for our template name since we named the custom post type &#8220;<em>link</em>&#8220;. But if you wanted to use a different template name for instance &#8220;<em>foorbarlink.php</em>&#8221; you can change it using this part of the code. If you&#8217;re happy with WordPress&#8217; default naming you can exclude this completely.<br />
<em><br />
Below is the function for a link type post, one that you might use in a tumble log. It&#8217;s a basic example of how to use the Custom Post Type feature in WordPress 3.0+</em><br />
<script src="http://gist.github.com/385765.js?file=custom_post_types.php"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://curtishenson.com/wordpress-custom-post-types-and-meta-boxes-example/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Creating a Chart on Your WordPress Archives Page</title>
		<link>http://curtishenson.com/creating-a-chart-on-your-wordpress-archives-page/</link>
		<comments>http://curtishenson.com/creating-a-chart-on-your-wordpress-archives-page/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 16:00:29 +0000</pubDate>
		<dc:creator>Curtis Henson</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://curtishenson.com/?p=638</guid>
		<description><![CDATA[One part of WordPress that I've never been overly impressed with is archives. This isn't so much a WordPress problem as it an archive problem, archives are inherently boring. As a result of this revelation I've spent some time thinking up new ways to present the information. My latest idea was adding charts to represent some of the data from the archives.]]></description>
			<content:encoded><![CDATA[<p>One part of WordPress that I&#8217;ve never been overly impressed with is archives. This isn&#8217;t so much a WordPress problem as it an archive problem, archives are inherently boring. As a result of this revelation I&#8217;ve spent some time thinking up new ways to present the information. My latest idea was adding charts to represent some of the data from the archives. This is a fairly simple function to output the info and style it as a chart. </p>
<p><em>If you want to use a flash or javascript chart, scroll to the bottom for a different function.</em></p>
<p><img src="http://curtishenson.com/wp-content/uploads/2009/07/chart.jpg" alt="chart" title="chart" class="alignnone size-full wp-image-650" /></p>
<h3>The Chart</h3>
<p>After looking for a lightweight flash or javascript charting solution, I decided for an archives page just plain CSS charts would be the way to go at first. So the output we are going for is something like this:</p>
<pre name="code" class="html">
&lt;dl class=&quot;barGraph 2008&quot;&gt;
	&lt;dt style=&quot;&quot; class=&quot;label&quot;&gt;&lt;a href=&quot;&quot;&gt;Jun&lt;/a&gt;&lt;/dt&gt;
	&lt;dd title=&quot;Jun&quot; style=&quot;height: 200px;&quot; class=&quot;bar Jun&quot;&gt;6&lt;/dd&gt;

	&lt;dt style=&quot;left: 55px;&quot; class=&quot;label&quot;&gt;&lt;a href=&quot;&quot;&gt;Jul&lt;/a&gt;&lt;/dt&gt;
	&lt;dd title=&quot;Jul&quot; style=&quot;height: 66.6667px; left: 55px;&quot; class=&quot;bar Jul&quot;&gt;2&lt;/dd&gt;

	&lt;dt style=&quot;left: 110px;&quot; class=&quot;label&quot;&gt;&lt;a href=&quot;&quot;&gt;Aug&lt;/a&gt;&lt;/dt&gt;
	&lt;dd title=&quot;Aug&quot; style=&quot;height: 100px; left: 110px;&quot; class=&quot;bar Aug&quot;&gt;3&lt;/dd&gt;

	&lt;dt style=&quot;left: 165px;&quot; class=&quot;label&quot;&gt;&lt;a href=&quot;&quot;&gt;Sep&lt;/a&gt;&lt;/dt&gt;
	&lt;dd title=&quot;Sep&quot; style=&quot;height: 133.333px; left: 165px;&quot; class=&quot;bar Sep&quot;&gt;4&lt;/dd&gt;

	&lt;dt style=&quot;left: 220px;&quot; class=&quot;label&quot;&gt;&lt;a href=&quot;&quot;&gt;Oct&lt;/a&gt;&lt;/dt&gt;
	&lt;dd title=&quot;Oct&quot; style=&quot;height: 166.667px; left: 220px;&quot; class=&quot;bar Oct&quot;&gt;5&lt;/dd&gt;

	&lt;dt style=&quot;left: 275px;&quot; class=&quot;label&quot;&gt;&lt;a href=&quot;&quot;&gt;Nov&lt;/a&gt;&lt;/dt&gt;
	&lt;dd title=&quot;Nov&quot; style=&quot;height: 100px; left: 275px;&quot; class=&quot;bar Nov&quot;&gt;3&lt;/dd&gt;

	&lt;dt style=&quot;left: 330px;&quot; class=&quot;label&quot;&gt;&lt;a href=&quot;&quot;&gt;Dec&lt;/a&gt;&lt;/dt&gt;
	&lt;dd title=&quot;Dec&quot; style=&quot;height: 66.6667px; left: 330px;&quot; class=&quot;bar Dec&quot;&gt;2&lt;/dd&gt;
&lt;/dl&gt;
</pre>
<h3>The Code</h3>
<p>The code in the function is essentially a Frankenstein of the wp_get_archives function from the WordPress core, and this <a href="http://www.terrill.ca/design/vertical_bar_graphs/">tutorial on creating vertical bar graphs</a>. It pulls the year, month and number of posts out of the database, then formats them into a list suitable for styling into a CSS chart.</p>
<pre name="code" class="php">
&lt;?php
function ch_archive_graph($args = ''){
	global $wpdb, $wp_locale;

	//template tag defaults
	$defaults = array(
		'graphYear' =&gt; '2007',
		'limit' =&gt; '13',
		'graphHeight' =&gt; '200',
		'xIncrement' =&gt; '55'
	);

	$maxHeight = 1;
	$scale = 1;

	$r = wp_parse_args( $args, $defaults );
	extract( $r, EXTR_SKIP );

	if ( '' != $limit ) {
		$limit = absint($limit + 1);
		$limit = ' LIMIT '.$limit;
	}

	$where = apply_filters('getarchives_where', &quot;WHERE post_type = 'post' AND post_status = 'publish'&quot;, $r );

	$query = &quot;SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb-&gt;posts $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC $limit&quot;;
	$key = md5($query);
	$cache = wp_cache_get( 'ch_archive_graph' , 'general');

	$output = '&lt;dl class=&quot;barGraph '.$graphYear.'&quot;&gt;';

	if ( !isset( $cache[ $key ] ) ) {
		$arcresults = $wpdb-&gt;get_results($query);
		$cache[ $key ] = $arcresults;
		wp_cache_add( 'ch_archive_graph', $cache, 'general' );
	} else {
		$arcresults = $cache[ $key ];
	}
	if ( $arcresults ) {

		//Loop through to find the highest number of posts
		foreach ( (array) $arcresults as $arcresult ) {
			//number of posts in a month
			$total = $arcresult-&gt;posts;
			if($maxHeight &lt; $total) $maxHeight = $total;
		}

		//Reverse the months
		$arcresults = array_reverse($arcresults);
		foreach ( (array) $arcresults as $arcresult ) {
			//Limit to one year
			if($arcresult-&gt;year == $graphYear){
				//Get month name, then appreviate, delete the second line if you want full month names
				$month = sprintf(__('%1$s'), $wp_locale-&gt;get_month($arcresult-&gt;month));
				$month = sprintf(__('%1$s'), $wp_locale-&gt;get_month_abbrev($month));
				//Get archive link
				$url = get_month_link( $arcresult-&gt;year, $arcresult-&gt;month );
				//Number of posts in the month
				$num_posts = $arcresult-&gt;posts;

				//Determine the scale and the height of the bar
				$scale = $graphHeight / $maxHeight;
				$height = ($arcresult-&gt;posts * $scale);

				//Put it all together
				$output .= &quot;&lt;dt class='label' style='left: &quot;.$xOffset.&quot;px;'&gt;&lt;a href=&quot;.$url.&quot;&gt;&quot;.$month.&quot;&lt;/a&gt;&lt;/dt&gt;&quot;;
				$output .= &quot;&lt;dd class='bar &quot;.$month.&quot;' style='height: &quot;.$height.&quot;px; left: &quot;.$xOffset.&quot;px;' title=&quot;.$month.&quot;&gt;&quot;.$num_posts.&quot;&lt;/dd&gt;&quot;;

				//Increase the offset for the next bar
				$xOffset = $xOffset + $xIncrement;
			}
		}
	}	

	$output .= &quot;&lt;/dl&gt;&quot;;
	echo $output;

}
</pre>
<h3>Styling the Chart with CSS </h3>
<p>Styling the chart is made easier by the definition list.</p>
<pre name="code" class="css">
.barGraph {
	height: 200px;
	margin: 0;
	padding: 0;
	position: relative;
	}

.barGraph dt {
	bottom: 0;
	list-style:none;
	margin: 0;
	padding: 0;
	position: absolute;
	text-align: center;
	width: 54px;
	}

.barGraph dd {
	border: 1px solid #005559;
	bottom: 0;
	list-style:none;
	margin: 0 0 1.5em 0;
	padding: 0;
	position: absolute;
	text-align: center;
	width: 50px;
	background-color: #00868B;
	border-right: 5px solid #005559;
	color: #fff;
	font-weight: bold;
	}

	.barGraph dd:hover {
		border: 1px solid #FA8000;
		background-color: #F5BA52;
		border-right: 5px solid #FA8000;
		color: #000;
		}
</pre>
<h3>How to use the Graph</h3>
<p>The function works just like any other template tag. Add the above function to your functions.php file and the CSS to style.css. Then call the chart in your template like so: <code>&lt;?php ch_archive_graph(); ?></code></p>
<p>The template tag also includes a few options to make customizing it easier:</p>
<ul>
<li>&#8216;<code>graphYear</code>&#8216;   this is the year of the archive you want to display</li>
<li>&#8216;<code>xIncrement</code>&#8216;   this is the width of the bars in the chart</li>
<li>&#8216;<code>graphHeight</code>&#8216;  this is the height in pixels of the chart</li>
<li>&#8216;<code>limit</code>&#8216;    this is number of posts you want to display</li>
</ul>
<p>Example:<br />
<code>&lt;?php ch_archive_graph('graphYear=2007&#038;xIncrement=40&#038;graphHeight=400&#038;limit=6'); ?></code></p>
<h3>Bonus: For Javascript Charts</h3>
<p>If you need the output for a javascript based chart, you only need to alter things a bit to get a javascript array or months and number of posts, then plug them into whatever charting you want to use.</p>
<pre name="code" class="php">
function ch_count_months_js_output($args = ''){
	global $wpdb, $wp_locale;

	$defaults = array(
		'limit' =&gt; '',
		'before' =&gt; ''
	);

	$r = wp_parse_args( $args, $defaults );
	extract( $r, EXTR_SKIP );


	$where = apply_filters('getarchives_where', &quot;WHERE post_type = 'post' AND post_status = 'publish'&quot;, $r );
	$join = apply_filters('getarchives_join', &quot;&quot;, $r);

	$query = &quot;SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb-&gt;posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC $limit&quot;;
	$key = md5($query);
	$cache = wp_cache_get( 'ch_count_months_js_output' , 'general');

	if ( !isset( $cache[ $key ] ) ) {
		$arcresults = $wpdb-&gt;get_results($query);
		$cache[ $key ] = $arcresults;
		wp_cache_add( 'ch_count_months_js_output', $cache, 'general' );
	} else {
		$arcresults = $cache[ $key ];
	}
	if ( $arcresults ) {
		$arcresults = array_reverse($arcresults);
		$posts = array();
		$months = array();
		foreach ( (array) $arcresults as $arcresult ) {
			$month = sprintf(__('%1$s'), $wp_locale-&gt;get_month($arcresult-&gt;month));
			array_push($months, $month);
			array_push($posts, $arcresult-&gt;posts);
		}
	}	
	print_r($months);
	print_r($posts); 

	echo '&lt;p type=&quot;text/javascript&quot;&gt;'; 
	echo 'var months = [&quot;', join($months,'&quot;,&quot;'), '&quot;];'; 
	echo 'var posts = [', join($posts,','), ']';
	echo '&lt;/p&gt;';
}
</pre>
<blockquote><p>Let me know if you use it or improve it!</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://curtishenson.com/creating-a-chart-on-your-wordpress-archives-page/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Press75 Releases Two New Plugins</title>
		<link>http://curtishenson.com/press75-releases-two-new-plugins/</link>
		<comments>http://curtishenson.com/press75-releases-two-new-plugins/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 22:27:07 +0000</pubDate>
		<dc:creator>Curtis Henson</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Curtis Henson]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[themes]]></category>

		<guid isPermaLink="false">http://curtishenson.com/?p=542</guid>
		<description><![CDATA[here are a few things that have been the realm of premium themes and some rare free themes: <strong>post thumbnails</strong>, and <strong>easy video embedding</strong>(<em>that doesn't suck</em>). Press75 just released two simple yet powerful and incredibly useful plugins.]]></description>
			<content:encoded><![CDATA[<div class="span-24">
<p>There are a few things that have been the realm of premium themes and some rare free themes: <strong>post thumbnails</strong>, and <strong>easy video embedding</strong>(<em>that doesn&#8217;t suck</em>). Press75 just released two simple yet powerful and incredibly useful plugins: <a href="http://www.press75.com/the-simple-post-thumbnails-wordpress-plugin/">Simple Post Thumbnails</a> and <a href="http://www.press75.com/the-simple-video-embedder-wordpress-plugin/">Simple Video Embedder</a>. <a href="http://www.press75.com/category/blog/">Go check them out</a>, and let Jason know how awesome they are. </p>
</div>
<div class="span-12">
<h4>Simple Post Thumbnails</h4>
<p>Easily add thumbnail capability to your theme. Previously most people used <a href="http://code.google.com/p/timthumb/">timthumb</a>, but Simple Post Thumbnails is a bit cleaner. The killer feature is the ability to upload from a URL to your own server.</p>
<blockquote><p>With the Simple Post Thumbnails plugin, adding thumbnail images to your posts is as easy as uploading any image (no editing required) and clicking the Update Post button. Upon upload, the plugin will re-size and crop the selected image according to whatever parameters you specify within the plugin configuration. To view this process in action, check out the Simple Post Thumbnails <a href="http://www.press75.com/docs/simple-post-thumbnails/simple-post-thumbnails.mp4">screencast</a>.</p></blockquote>
</div>
<div class="span-12 last">
<a href="http://www.press75.com/the-simple-post-thumbnails-wordpress-plugin/"><img src="http://curtishenson.com/wp-content/uploads/2009/04/thumbs.jpg" alt="thumbs" title="thumbs" width="470" height="288" class="alignnone size-full wp-image-549" /></a>
</div>
<div class="span-12">
<h4>Simple Video Encoder</h4>
<p>There are a few video embed plugins for WordPress, but I don&#8217;t like most of them, they are heavy weighted and often add unnecessary headaches for theme developers and users. The <a href="http://www.press75.com/the-simple-video-embedder-wordpress-plugin/">Simple Video Embedder</a> is a simple and effective way to add video embedding to your theme.  </p>
<blockquote><p>With the Simple Video Embedder plugin, adding video to your post is as easy as pasting the URL for the video you want to add within a field, and then click submit. You can even provide simple width and height parameters to size your video to match your theme. Currently, this URL embed method works perfectly with several services including Vimeo.com, YouTube.com, MetaCafe.com, Revver.com, Google Video and Seesmic.com. Or, of you want to host your own video, the plugin is also compatible with FLV (Flash Video) and Quicktime formats.</p></blockquote>
</div>
<div class="span-12 last">
<a href="http://www.press75.com/the-simple-video-embedder-wordpress-plugin/"><img src="http://curtishenson.com/wp-content/uploads/2009/04/videoembedder.jpg" alt="videoembedder" title="videoembedder" width="470" height="472" class="alignnone size-full wp-image-550" /></a>
</div>
]]></content:encoded>
			<wfw:commentRss>http://curtishenson.com/press75-releases-two-new-plugins/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
<enclosure url="http://www.press75.com/docs/simple-post-thumbnails/simple-post-thumbnails.mp4" length="13632118" type="video/mp4" />
		</item>
		<item>
		<title>DRY WordPress Theme Coding</title>
		<link>http://curtishenson.com/dry-wordpress-theme-coding/</link>
		<comments>http://curtishenson.com/dry-wordpress-theme-coding/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 23:33:28 +0000</pubDate>
		<dc:creator>Curtis Henson</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://curtishenson.com/?p=509</guid>
		<description><![CDATA[Don't Repeat Yourself is the rule, the name of the game, and what you should apply to just about everything you code. So what is DRY? In it's simplest form it means don't write the same code over and over again.  ]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t Repeat Yourself is the rule, the name of the game, and what you should apply to just about everything you code. It is a simple principle which seems to be totally ignored when it comes to WordPress themes. So what is DRY? In it&#8217;s simplest form it means don&#8217;t write the same code over and over again.  </p>
<p>WordPress themes seem prone to this sort of repeating your code. I believe this mostly has to do with WordPress theme developers not being &#8220;developers&#8221; in a traditional sense, more designers who can code.  This habit of repeating code also comes from introductory tutorials and the like which have you creating templates which are mostly the same thing over and over.</p>
<p>Themes are getting more and more advanced, WordPress itself is getting more flexible. As these themes get more complex they need to be simpler. I learned this with my Checkmate theme. It was quickly getting out of hand with the numerous files, lack of organization, and changing code took entirely too long. </p>
<h3>K.I.S.S.</h3>
<p>I want to rock and roll all night, and party every day too, but I&#8217;m busy changing one line of code&#8230;in ten different template files.  That shouldn&#8217;t happen, my new goal is now to create the lightest template files I can, and be heavy on other tools. I also like to cut down on the number of templates I have.  The simpler the file structure and code the easier to change or update.</p>
<p>HTML and CSS strive to separate style from content, so you should also try to separate logic from your views.  Essentially separate your php from your html as much as possible.  This is much more apparent on really complex themes requiring more than your basic template tags.</p>
<h3>The Tools</h3>
<p>So what tools are there to help in the endeavor to not repeat ourselves? There are quite a few stupidly useful ones.</p>
<h4>Template Hierarchy</h4>
<p>The first step is understanding what files WordPress looks for at any given time. This can help you strategically use files and save yourself a lot of copying and pasting.  The best place to learn about hierarchy is the <a href="http://codex.wordpress.org/Template_Hierarchy">WordPress Codex Template Hierarchy</a> page.</p>
<p>A quick example of how I use the hierarchy is by using archive.php to display category, tag and author pages. Often these pages are the exact same with minimal changes. Using conditional statements you can serve parts of the page depending on what is requested.  <a href="http://github.com/curtishenson/checkmate/blob/bb636855d306fc1d5bc79fced9240ed7c10feb35/archive.php">Checkmate&#8217;s archive file</a> uses this type of system to dynamically display information for tags, categories, or author information.</p>
<h4>Conditional Statements</h4>
<p>After you know the template hierarchy, you&#8217;ll need to understand the use of conditional statements to make the most of your template files. I&#8217;ve written twice about conditional statements: <a href="http://curtishenson.com/wordpress-conditional-tags-write-less-code/">Write Less Code</a>, and <a href="http://curtishenson.com/complex-wordpress-conditional-tags/">Complex WordPress Conditional Tags</a>.  The WordPress codex page on <a href="http://codex.wordpress.org/Conditional_Tags">Conditional Tags</a> will explain everything in great detail.</p>
<p>Conditional tags are just ways to create powerful PHP if else statements very easily. You can use them to dynamically display select parts of a template only in certain specific circumstances.</p>
<h4>The Functions File</h4>
<p>The functions file is your friend, a powerful friend, a good friend, a wing man of sorts.  I use the functions file to call all my other goodies, allowing me to keep a nice clean structured theme folder. Pearsonified has a great article on <a href="http://www.pearsonified.com/2008/05/how-to-use-wordpress-functions.php">how to use the functions file</a>. Toxane also has a good article with some examples for <a href="http://www.flowdrops.com/wordpress/wordpress-themes-functions-php/">WordPress&#8217; function file</a>.  The function file can be used </p>
<h4>PHP Itself</h4>
<p>Some basic PHP can go a long way coupled with some of WordPress&#8217; functions. Learning to read the API and knowing the lingo can go a long way in accomplishing whatever you want.</p>
<h4>Helper Functions</h4>
<p>In the near future I&#8217;ll be releasing my <a href="http://curtishenson.com/wordpress-theme-tools-project-announcement/">WordPress Tools Project</a>, which is a bunch of functions all ready to be included into themes to help do some mundane things. But you don&#8217;t have to wait for me, make up your own, go back into old themes and abstract out some of the advanced things you do. Always using the same HTML code around a template tag? Put it into a function and make your own template tag.</p>
<p>I&#8217;ve started posting some of these functions to serve as examples: <a href="http://curtishenson.com/wordpress-navigation-helper-function-comments-and-posts/">WordPress Navigation Helper</a>, and <a href="http://curtishenson.com/dynamic-multi-level-page-menus-in-wordpress/">Dynamic Multi-Level Page Menus</a>.</p>
<h3>Some Tips</h3>
<p>Try to keep things organized, for instance put all your javascript in one folder, all your php functions in another, css in another. </p>
<p>Develop a solid framework. I find myself working off Checkmate a lot, I know it very well and know what can be stripped out immediately.  Developing a solid theme and releasing is a great way to find errors in your code, essentially it is like having thousands of testers in all sorts of different scenarios.</p>
<p>Learn from other themes.  There are a few themes that do this extremely well. <a href="http://themeshaper.com/thematic-for-wordpress/">Thematic</a> is one of my favorites.</p>
]]></content:encoded>
			<wfw:commentRss>http://curtishenson.com/dry-wordpress-theme-coding/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dynamic Multi-level Page Menus in WordPress</title>
		<link>http://curtishenson.com/dynamic-multi-level-page-menus-in-wordpress/</link>
		<comments>http://curtishenson.com/dynamic-multi-level-page-menus-in-wordpress/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 00:15:08 +0000</pubDate>
		<dc:creator>Curtis Henson</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[word]]></category>

		<guid isPermaLink="false">http://curtishenson.com/?p=497</guid>
		<description><![CDATA[Something I often see while trolling boards (<em>and engaging in flame wars</em>) is the question: "<strong>How do I display a menu with a parent level and child level, but only if the current page actually has child pages?</strong>".]]></description>
			<content:encoded><![CDATA[<p>Something I often see while trolling boards (<em>and engaging in flame wars</em>) is the question: &#8220;<strong>How do I display a menu with a parent level and child level, but only if the current page actually has child pages?</strong>&#8221; or something similar, but better phrased.  The gist is, all the basic WordPress template functions don&#8217;t really do this, at least not very well.  You can use a few functions to get something close, but it often is a compromise with the end result not quite what the designer had envisioned. I say no more!</p>
<h3>What it actually does</h3>
<p>The purpose of this article is to give you a function you can pop into a theme just like a regular template tag (<code>wp_list_pages</code>) but with some changed functionality.  What you&#8217;ll get is a top level menu, nothing fancy, basic use of wp_list_pages really, but this top level is always there.  You also get child menus, as many as you need. The child menus only display if the page actually has children, and it only displays one level of children instead of all of them.</p>
<h3>The beginning of a beast</h3>
<p>I&#8217;m not gonna lie, this is gonna get thick and fast, in fact the code barely makes sense to me and I wrote it. Here&#8217;s the short: we display a top level menu(<em>easy</em>), we check if a page is a child(<em>easy</em>), we check if the page has children itself(<em>weird hack</em>), we count the page&#8217;s parents and display the menu accordingly(<em>huh?</em>).</p>
<h4>The top level</h4>
<p>We&#8217;ll start with the top level menu, this is just a call to the wp_list_pages function, nothing fancy here. Output is generated with an unordered list with a few class names for styling.</p>
<pre class="php" name="code">
//Multi-level pages menu
function wptt_multilevel_menu() {
	global $post;
	// Top level menu is always displayed
	$top_level = wp_list_pages('title_li=&amp;depth=1&amp;sort_column=menu_order&amp;echo=0');

	// Put it all together
	$menu = '&lt;ul class=&quot;menu top_level&quot;&gt;';
	$menu .= $top_level;
	$menu .= '&lt;/ul&gt;';

	print $menu;
}
</pre>
<h4>Displaying the children</h4>
<p>The meat of this example is this next part, displaying the children is in thought a very simple process, in practice it takes a bit of pounding a square peg into a round hole.  We are still using the wp_list_pages function, and most of this code has one purpose, <strong>to determine the right depth to pass to wp_list_pages</strong>.</p>
<p>Initially we&#8217;ll check if a page has any parent pages using <code>$post->ancestors</code> and count the ancestors. I count the ancestors to determine the depth used later. Then check if a page has any more children.  We&#8217;ll then separate those pages with children and those without.</p>
<pre class="php" name="code">
&lt;?php
// Check if a page has any parent pages
	if ($post-&gt;ancestors) {

		// How many ancestors does this page have? Then subtract by 1 to adjust for top level
		$n = count($post-&gt;ancestors);
		$n = $n - 1;

		// Get the page's children, if it has any
		$pages = get_pages();
		$page_children = get_page_children($post-&gt;ID, $pages);

		// Checks if a page has children
		if (!empty($page_children)) {
			$children = wp_list_pages(&quot;title_li=&amp;child_of=&quot;. $post-&gt;ancestors[$n] .&quot;&amp;echo=0&amp;sort_column=menu_order&amp;depth=&quot; . ($n + 2));
		} else { // If the page doesn't have children
			$children = wp_list_pages(&quot;title_li=&amp;child_of=&quot;. $post-&gt;ancestors[$n] .&quot;&amp;echo=0&amp;sort_column=menu_order&amp;depth=&quot; . ($n + 1));
		}

	} else {
		$children = wp_list_pages(&quot;title_li=&amp;child_of=&quot;. $post-&gt;ID .&quot;&amp;echo=0&amp;sort_column=menu_order&amp;depth=1&quot;);
	}
?&gt;
</pre>
<p>All of the counting done above(<em>$n, depth, ancestors, blah blah</em>) is all done in order to display only the first child level. This way you are not showing all the children of the top level page.</p>
<h3>The whole function</h3>
<p>In the final function I&#8217;ve added some output for the children and combined everything above.</p>
<blockquote><p>Updated 4/20/09 &#8211; the function has changed slightly since the explanation above.</p></blockquote>
<pre class="php" name="code">
//Multi-level pages menu
function wptt_multilevel_menu() {
	global $post;
	// Top level menu is always displayed
	$top_level = wp_list_pages('title_li=&amp;depth=1&amp;sort_column=menu_order&amp;echo=0');

	// Get post ancestors 
	$post_ancestors = get_post_ancestors($post);

	// Check if a page has any parent pages
	if ($post_ancestors) {

		//get the top page id
		$top_page = $post_ancestors ? end($post_ancestors) : $post-&gt;ID;

		// How many ancestors does this page have? Counts the array adds one.
		$n = count($post_ancestors) + 1;

		// Get the pages children, if it has any
		$pages = get_pages();
		$page_children = get_page_children($post-&gt;ID, $pages);

		// Checks if a page has children
		if (!empty($page_children)) {
			$children = wp_list_pages(&quot;title_li=&amp;child_of=&quot;. $top_page .&quot;&amp;echo=0&amp;sort_column=menu_order&amp;depth=&quot; . $n);
		} else { // If the page doesn't have children
			$children = wp_list_pages(&quot;title_li=&amp;child_of=&quot;. $top_page .&quot;&amp;echo=0&amp;sort_column=menu_order&amp;depth=&quot; . ($n - 1));
		}

	} else {
		$children = wp_list_pages(&quot;title_li=&amp;child_of=&quot;. $post-&gt;ID .&quot;&amp;echo=0&amp;sort_column=menu_order&amp;depth=1&quot;);
	}

	// Put it all together
	$menu = '&lt;ul class=&quot;menu top_level&quot;&gt;';
	$menu .= $top_level;
	$menu .= '&lt;/ul&gt;';
	// Only show child navigation if there are children
	if ( $children ) {
		$menu .= '&lt;ul class=&quot;menu subpages&quot;&gt;';
		$menu .= $children;
		$menu .= '&lt;/ul&gt;';
	}
	print $menu;
}
</pre>
<h3>The future and spaceships</h3>
<p>That is one way to do multiple level menus in wordpress, right now this function is only using pages, but I will be expanding it to use categories as well.  There are actually quite a few ways I want to expand this in order to make it truly useful.  This function is part of the larger <a href="http://curtishenson.com/wordpress-theme-tools-project-announcement/">WordPress Theme Tools project</a> that I&#8217;m starting. If you have any suggestions for this, find a bug, or know a better way, let me know!</p>
<p><strong>Note</strong>: I&#8217;ve updated the code on 4/20/09 but the function still works the same. As it is right now <strong>the sub pages are displayed in the default nested way</strong> that WordPress naturally does it.  <em>The benefit of the function is that it only shows one level under the parent page instead of hard coding the depth or showing all the children.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://curtishenson.com/dynamic-multi-level-page-menus-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>WordPress Navigation Helper Function, Comments and Posts</title>
		<link>http://curtishenson.com/wordpress-navigation-helper-function-comments-and-posts/</link>
		<comments>http://curtishenson.com/wordpress-navigation-helper-function-comments-and-posts/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 23:26:25 +0000</pubDate>
		<dc:creator>Curtis Henson</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://curtishenson.com/?p=466</guid>
		<description><![CDATA[A quick tip on only displaying navigation blocks when there is actually navigation to be displayed. Oh and a full navigation helper function you can drop into your themes to keep things nice and clean.]]></description>
			<content:encoded><![CDATA[<p>This post started as a quick little tip on how to hide navigation blocks when there weren&#8217;t any pages to actually link to. That was a good post, it was intelligent, well thought out, and helpful. But like all things intelligent, well thought out, and helpful, it was quickly scrapped. </p>
<p>While coding the new theme for curtishenson.com I had a problem, <strong>pagination blocks would show even when there were no pages to link to</strong>(not <em>technically</em> wordpress&#8217; fault), turns out it is a pretty easy fix. For post pagination blocks wrap the navigation in this:</p>
<pre name="code" class="php">
&lt;?php global $wp_query;
	$total_pages = $wp_query-&gt;max_num_pages;
		if ( $total_pages &gt; 1 ) {
			//Your navigation goes here
		}
?&gt;
</pre>
<p>This grabs the total amount pages, checks if it is greater than one, then shows the navigation if there is more than one page. For comment pagination in WordPress 2.7+ do it like this:</p>
<pre name="code" class="php">
$total_pages = get_comment_pages_count();
	if ( $total_pages &gt; 1 ) {
		//Your navigation goes here
	}
?&gt;
</pre>
<p>The subtle difference is the use of the <strong>get_comment_pages_count</strong> function. Otherwise you&#8217;re just checking to see if there is more than one page.</p>
<h3>A Helper Function</h3>
<p>The first time I saw a helper it was in a ruby on rails program. Seemed like a good idea, don&#8217;t know why I hadn&#8217;t used this most basic implementation of DRY (<em>Don&#8217;t Repeat Yourself</em>) theory in WordPress themes. So while I was copy and pasting this code I decided it would be <strong>much easier to lump it into one function</strong>. The benefits: lighter template files, change the function once and the whole site changes. </p>
<p>This HTML bits will probably need to be changed to your liking, but this little diddy should help anyone with their themes. Just copy and paste the function in your <strong>functions.php</strong> file, then call it in your theme in place of the navigation like so: <code>&lt;?php ch_navigation_helper(); ?></code></p>
<p>I have some ideas to extend this into a truly helpful &#8230;helper. I&#8217;ll be including it in my new <a href="http://curtishenson.com/wordpress-theme-tools-project-announcement/">WP Theme Tools Project</a> for sure. If you extend it let me know!</p>
<blockquote><p>Note: This function only works with WordPress 2.7.1</p></blockquote>
<pre name="code" class="php">
&lt;?php
// Navigation Helper Function 
//http://curtishenson.com/wordpress-navigation-helper-function-comments-and-posts  
function ch_navigation_helper(){
	global $wp_query;
	// For templates like index, search, archive, etc.
	if ( !is_singular() ) {
		$total_pages = $wp_query-&gt;max_num_pages;
			if ( $total_pages &gt; 1 ) { 
			$s = '';
			$s .= '&lt;div class=&quot;navigation clearfix&quot;&gt;';
			$s .= '&lt;span class=&quot;alignleft&quot;&gt;' . get_next_posts_link('Previous Entries') . '&lt;/span&gt;';
			$s .= '&lt;span class=&quot;alignright&quot;&gt;' . get_previous_posts_link('Newer Entries') . '&lt;/span&gt;';
			$s .= '&lt;/div&gt;';
			echo $s;
		}
	}

	// For paginated comments in WP 2.7+
	if ( is_singular() &amp;&amp; get_option('page_comments') ) {
		$total_pages = get_comment_pages_count();
		if ( $total_pages &gt; 1 ) { 
			$s = '';
			$s .= '&lt;div class=&quot;navigation clearfix&quot;&gt;';
			$s .= '&lt;div class=&quot;alignleft&quot;&gt;';
			$s .= get_previous_comments_link('Older Comments');
			$s .= '&lt;/div&gt;';
			$s .= '&lt;div class=&quot;alignright&quot;&gt;';
			$s .= get_next_comments_link('Newer Comments');
			$s .= '&lt;/div&gt;&lt;/div&gt;';
			echo $s;
		} 
	}
}

?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://curtishenson.com/wordpress-navigation-helper-function-comments-and-posts/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>WordPress Theme Tools Project Announcement</title>
		<link>http://curtishenson.com/wordpress-theme-tools-project-announcement/</link>
		<comments>http://curtishenson.com/wordpress-theme-tools-project-announcement/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 20:44:02 +0000</pubDate>
		<dc:creator>Curtis Henson</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://curtishenson.com/?p=457</guid>
		<description><![CDATA[A new project for WordPress theme developers which will make creating advanced themes easier and quicker. The project will be a library of code that can be dropped into a theme and give the developer quick access to things like theme options, custom widgets, and tailor made functions.]]></description>
			<content:encoded><![CDATA[<p>An &#8220;<em>announcement</em>&#8221; of a project, sounds exciting doesn&#8217;t it? Well if you develop WordPress themes you should be excited, or at least somewhat amused.  I&#8217;m planning on developing a set of what I call &#8220;tools&#8221; for you WordPress themers out there. It is still in it&#8217;s planning stage at the moment but I&#8217;m going to list what it is going to have so far because <strong>I want your input</strong> on what you want, and how you think it should work.</p>
<h3>The Basic Idea</h3>
<p>When I develop themes I spend a lot of time doing the same things, or copy and pasting code from my other themes and tweaking. Things like <strong>theme options, basic functions, filters, widgets</strong>.  I also have had some trouble keeping things like widgets up to date(thank God WordPress is so forgiving).</p>
<p>I want to build a library that can be dropped into any theme, and be <strong>easily customized</strong> to suit the needs of that theme. This is the basic idea behind the tools project.</p>
<h3>Theme Options</h3>
<p>I think theme options are an integral part of modern WordPress themes.  Themes are more complex than ever and I can&#8217;t imagine developing a theme without options.  Theme options can be a pain, but they don&#8217;t have to be. The tools project&#8217;s first feature (<em>and already almost done</em>) is a library which makes creating theme options as easy as creating a few arrays.  Drop in the files, customize a file and you are good to go. No more searching through long files of code.</p>
<h3>Basic Functions and Filters</h3>
<p>Custom functions can greatly help a theme designer, whether it is doing complex things or just helping clean up the source code.  I have a few functions and filters planned already, but this <strong>could definitely use some input</strong> as I&#8217;m sure other people could add to this part.</p>
<h3>Widgets</h3>
<p>Custom widgets are nice&#8230;especially when they work right. Custom widgets are also a huge selling point (or give away point??) for themes.  And custom widgets are also usually a huge pain in my ass.  It is a lot of code, and a lot of my code is now outdated due to WordPress 2.7.  I&#8217;m not sure how easily customizable the widgets will be though, any ideas on how that could work are welcome.</p>
<h3>Widget Areas</h3>
<p>So far this is just a bunch of arrays premade for the theme.  Not sure if there is anything else that can make this basic feature better.</p>
<h3>Your Input</h3>
<p>That is what I currently have in mind for the project, however I&#8217;d like to extend that further.  l&#8217;ll need the input of people who build themes. <strong>What do you want? How do you think it should work? Any ideas for more features?</strong> </p>
<p>I&#8217;m going to upload this on github once I have a good, functioning base so people will be able to branch it and commit changes and updates.</p>
]]></content:encoded>
			<wfw:commentRss>http://curtishenson.com/wordpress-theme-tools-project-announcement/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Separating and Hiding Trackbacks with Jquery in WordPress 2.7</title>
		<link>http://curtishenson.com/separating-and-hiding-trackbacks-with-jquery-in-wordpress-27/</link>
		<comments>http://curtishenson.com/separating-and-hiding-trackbacks-with-jquery-in-wordpress-27/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 16:00:33 +0000</pubDate>
		<dc:creator>Curtis Henson</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://curtishenson.com/?p=432</guid>
		<description><![CDATA[If you're designing and coding themes for WordPress, please, I beg you, for love of all that is digitized and Tron like, separate your trackbacks and pingbacks from your comment threads. This tutorial goes over separating comments and pings and adding a little jQuery spice.]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re designing and coding themes for WordPress, please, I beg you, for love of all that is digitized and Tron like, separate your trackbacks and pingbacks from your comment threads. There is nothing more frustrating than having to navigate through a horde of unholy spam links to see the next comment in a thread. I also personally believe(ie I have no proof whatsoever) that a comment threat mucked with trackbacks correlates directly with less commenting. But trackbacks aren&#8217;t all bad, some people (not me) use them to find out more about the blog post, theme, story, whatever&#8230;so I wouldn&#8217;t just toss them aside like fruit cake.</p>
<p>If you look at most new well thought out themes, trackbacks are separated into another tab, or somehow minimized/hidden from the user that doesn&#8217;t want them. WordPress 2.7 changed the commenting code quite a bit, and now separating everything is even easier. Add a little jQuery magic and you can hide and show those trackbacks on demand. Enough with this banter, lets rock out with our text-editor out.</p>
<h3>First a little catchup</h3>
<p>So things are a wee bit different in the ol&#8217; comment file in WordPress 2.7. I highly suggest taking a peek at Otto&#8217;s <a href="http://ottodestruct.com/blog/2008/09/29/wordpress-27-comments-enhancements/">WordPress 2.7 Comments Enhancements</a> if you haven&#8217;t already. He outlines how the new comment loop works, and all the spiffy javascript for threaded comments.</p>
<p>Once you got a grasp on the comment changes in 2.7, checkout Matt&#8217;s article on <a href="http://sivel.net/2008/10/wp-27-comment-separation/">separating pings from comments</a>. I&#8217;m not going to go into too much detail so if you find yourself not understanding a part of the code, try checking out those articles.</p>
<h3>Separation makes the heart grow fonder of pings</h3>
<p>I think that is the saying. Lets start with the comment loop, first the whole thing, </p>
<pre name="code" class="php">
if ( have_comments() ) : ?&gt;
	&lt;h3 class=&quot;comment_title&quot;&gt;&lt;?php comments_number('No Comments', 'One Comment', '% Comments' );?&gt;&lt;/h3&gt;
		&lt;ol class=&quot;commentlist&quot; id=&quot;singlecomments&quot;&gt;
			&lt;?php wp_list_comments(array('avatar_size'=&gt;48, 'reply_text'=&gt;'Reply', 'type'=&gt;'comment')); ?&gt;
		&lt;/ol&gt;

	&lt;h3 class=&quot;trackback_title&quot;&gt;Trackbacks / Pingbacks&lt;/h3&gt;
	&lt;a href=&quot;#pings&quot; class=&quot;show_trackbacks&quot;&gt;show trackbacks&lt;/a&gt;
		&lt;ol id=&quot;pings&quot; class=&quot;trackback&quot;&gt;
			&lt;?php wp_list_comments('type=pings'); ?&gt;
		&lt;/ol&gt;

	&lt;div class=&quot;comments-navigation&quot;&gt;
		&lt;div class=&quot;alignleft&quot;&gt;&lt;?php previous_comments_link() ?&gt;&lt;/div&gt;
		&lt;div class=&quot;alignright&quot;&gt;&lt;?php next_comments_link() ?&gt;&lt;/div&gt;
	&lt;/div&gt;
 &lt;?php else : // this is displayed if there are no comments so far ?&gt;

	&lt;?php if ('open' == $post-&gt;comment_status) :
		// If comments are open, but there are no comments.
	else : 
		// comments are closed 
	endif;
endif;
</pre>
<p>There is the comment loop with the trackbacks already separated. The only trick to the separation is setting the &#8216;<strong>type</strong>&#8216; option for the <code>wp_list_comments</code> function. Set the &#8216;type&#8217; to &#8216;comment&#8217;, for comments, and pings for &#8230;well pings(trackbacks). Simple enough right?  Let&#8217;s take a closer look at the HTML.</p>
<pre name="code" class="html">
&lt;h3 class=&quot;comment_title&quot;&gt;&lt;?php comments_number('No Comments', 'One Comment', '% Comments' );?&gt;&lt;/h3&gt;
		&lt;ol class=&quot;commentlist&quot; id=&quot;singlecomments&quot;&gt;
			&lt;?php wp_list_comments(array('avatar_size'=&gt;48, 'reply_text'=&gt;'Reply', 'type'=&gt;'comment')); ?&gt;
		&lt;/ol&gt;

	&lt;h3 class=&quot;trackback_title&quot;&gt;Trackbacks / Pingbacks&lt;/h3&gt;
	&lt;a href=&quot;#pings&quot; class=&quot;show_trackbacks&quot;&gt;show trackbacks&lt;/a&gt;
		&lt;ol id=&quot;pings&quot; class=&quot;trackback&quot;&gt;
			&lt;?php wp_list_comments('type=pings'); ?&gt;
		&lt;/ol&gt;
</pre>
<p>This is really the meat of the code, you can see the two blocks of code, one for comments and one for pings. The only real differences are setting the &#8216;type&#8217; for wp_list_comments and changing the id and class names for styling. There is also one addition for the pings, a link to show them(it has a class of &#8216;show_trackbacks&#8217;). You can either put this link in the actual code, or inject it using javascript.</p>
<h3>The jQuery</h3>
<p>There&#8217;s a few ways to do this but I&#8217;m going to go with a simple slide up and slide down. First we&#8217;ll hide the trackbacks by calling <code>slideUp()</code> then add a function to detect the click on our show_trackbacks link which will call <code>slideDown()</code>.</p>
<pre name="code" class="js">
$('ol.trackback').slideUp();
$('.show_trackbacks').click(function(){
	$('ol.trackback').slideDown();
});
</pre>
<p>That&#8217;s it?? Yeah, pretty simple actually, so I&#8217;ll leave you with something else useful. A full comment file ready for wordpress 2.7.</p>
<h3>The whole thing</h3>
<pre name="code" class="php">
&lt;?php // Do not delete these lines
if (!empty($_SERVER['SCRIPT_FILENAME']) &amp;&amp; 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
	die ('Please do not load this page directly. Thanks!');
if ( post_password_required() ) { ?&gt;
	&lt;p class=&quot;nocomments&quot;&gt;This post is password protected. Enter the password to view comments.&lt;/p&gt;
&lt;?php
	return;
}

// add a microid to all the comments
function comment_add_microid($classes) {
	$c_email=get_comment_author_email();
	$c_url=get_comment_author_url();
	if (!empty($c_email) &amp;&amp; !empty($c_url)) {
		$microid = 'microid-mailto+http:sha1:' . sha1(sha1('mailto:'.$c_email).sha1($c_url));
		$classes[] = $microid;
	}
	return $classes;	
}
add_filter('comment_class','comment_add_microid');

//Change date format
function change_comment_date($datestring, $dateformat) {
global $comment;
return mysql2date('F j y', $comment-&gt;comment_date);
}
add_filter('get_comment_date','change_comment_date',10,2);

// show the comments
if ( have_comments() ) : ?&gt;
	&lt;h3 class=&quot;comment_title&quot;&gt;&lt;?php comments_number('No Comments', 'One Comment', '% Comments' );?&gt;&lt;/h3&gt;
		&lt;ol class=&quot;commentlist&quot; id=&quot;singlecomments&quot;&gt;
			&lt;?php wp_list_comments(array('avatar_size'=&gt;48, 'reply_text'=&gt;'Reply', 'type'=&gt;'comment')); ?&gt;
		&lt;/ol&gt;

	&lt;h3 class=&quot;trackback_title&quot;&gt;Trackbacks / Pingbacks&lt;/h3&gt;
	&lt;a href=&quot;#pings&quot; class=&quot;show_trackbacks&quot;&gt;show trackbacks&lt;/a&gt;
		&lt;ol id=&quot;pings&quot; class=&quot;trackback&quot;&gt;
			&lt;?php wp_list_comments('type=pings'); ?&gt;
		&lt;/ol&gt;

	&lt;div class=&quot;comments-navigation&quot;&gt;
		&lt;div class=&quot;alignleft&quot;&gt;&lt;?php previous_comments_link() ?&gt;&lt;/div&gt;
		&lt;div class=&quot;alignright&quot;&gt;&lt;?php next_comments_link() ?&gt;&lt;/div&gt;
	&lt;/div&gt;
 &lt;?php else : // this is displayed if there are no comments so far ?&gt;

	&lt;?php if ('open' == $post-&gt;comment_status) :
		// If comments are open, but there are no comments.
	else : 
		// comments are closed 
	endif;
endif; 

if ('open' == $post-&gt; comment_status) : 

// show the form
?&gt;
&lt;div id=&quot;respond&quot;&gt;&lt;h3&gt;&lt;?php comment_form_title( 'Leave a Reply', 'Leave a Reply to %s' ); ?&gt;&lt;/h3&gt;

&lt;div id=&quot;cancel-comment-reply&quot;&gt;
	&lt;small&gt;&lt;?php cancel_comment_reply_link(); ?&gt;&lt;/small&gt;
&lt;/div&gt;

&lt;?php if ( get_option('comment_registration') &amp;&amp; !$user_ID ) : ?&gt;

&lt;p&gt;You must be &lt;a href=&quot;&lt;?php echo get_option('siteurl'); ?&gt;/wp-login.php?redirect_to=&lt;?php echo urlencode(get_permalink()); ?&gt;&quot;&gt;logged in&lt;/a&gt; to post a comment.&lt;/p&gt;

&lt;?php else : ?&gt;

&lt;form action=&quot;&lt;?php echo get_option('siteurl'); ?&gt;/wp-comments-post.php&quot; method=&quot;post&quot; id=&quot;commentform&quot; class=&quot;span-17&quot;&gt;

	&lt;div&gt;
	&lt;?php comment_id_fields(); ?&gt;
	&lt;input type=&quot;hidden&quot; name=&quot;redirect_to&quot; value=&quot;&lt;?php echo htmlspecialchars($_SERVER[&quot;REQUEST_URI&quot;]); ?&gt;&quot; /&gt;&lt;/div&gt;

	&lt;p&gt;&lt;small&gt;&lt;strong&gt;XHTML:&lt;/strong&gt; You can use these tags: &lt;?php echo allowed_tags(); ?&gt;&lt;/small&gt;&lt;/p&gt;

	&lt;p&gt;&lt;textarea name=&quot;comment&quot; id=&quot;comment&quot; cols=&quot;10&quot; rows=&quot;10&quot; tabindex=&quot;4&quot;&gt;&lt;/textarea&gt;&lt;/p&gt;

	&lt;?php if (get_option(&quot;comment_moderation&quot;) == &quot;1&quot;) { ?&gt;
	 &lt;p&gt;&lt;small&gt;&lt;strong&gt;Please note:&lt;/strong&gt; Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.&lt;/small&gt;&lt;/p&gt;
	&lt;?php } ?&gt;


&lt;?php if ( $user_ID ) : ?&gt;

&lt;p class=&quot;loggedin&quot;&gt;Logged in as &lt;a href=&quot;&lt;?php echo get_option('siteurl'); ?&gt;/wp-admin/profile.php&quot;&gt;&lt;?php echo $user_identity; ?&gt;&lt;/a&gt;.
&lt;a href=&quot;&lt;?php echo wp_logout_url(get_permalink()); ?&gt;&quot; title=&quot;Log out of this account&quot;&gt;Logout &amp;raquo;&lt;/a&gt;&lt;/p&gt;

&lt;?php else : ?&gt;

&lt;p&gt;&lt;label for=&quot;author&quot;&gt;&lt;small&gt;Name &lt;?php if ($req) echo &quot;(required)&quot;; ?&gt;&lt;/small&gt;&lt;/label&gt;
&lt;input type=&quot;text&quot; name=&quot;author&quot; id=&quot;author&quot; value=&quot;&lt;?php echo $comment_author; ?&gt;&quot; size=&quot;22&quot; tabindex=&quot;1&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;label for=&quot;email&quot;&gt;&lt;small&gt;Email &lt;?php if ($req) echo &quot;(required)&quot;; ?&gt;&lt;/small&gt;&lt;/label&gt;
&lt;input type=&quot;text&quot; name=&quot;email&quot; id=&quot;email&quot; value=&quot;&lt;?php echo $comment_author_email; ?&gt;&quot; size=&quot;22&quot; tabindex=&quot;2&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;label for=&quot;url&quot;&gt;&lt;small&gt;Website&lt;/small&gt;&lt;/label&gt;
&lt;input type=&quot;text&quot; name=&quot;url&quot; id=&quot;url&quot; value=&quot;&lt;?php echo $comment_author_url; ?&gt;&quot; size=&quot;22&quot; tabindex=&quot;3&quot; /&gt;&lt;/p&gt;

&lt;?php endif; ?&gt;

&lt;p&gt;&lt;input name=&quot;submit&quot; type=&quot;submit&quot; id=&quot;submit&quot; tabindex=&quot;5&quot; value=&quot;Submit Comment&quot; /&gt;&lt;/p&gt;
&lt;?php do_action('comment_form', $post-&gt;ID); ?&gt;
&lt;/div&gt;

&lt;/form&gt;

&lt;?php 
endif;

endif;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://curtishenson.com/separating-and-hiding-trackbacks-with-jquery-in-wordpress-27/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Checkmate 2.0: A Free Premium WordPress Theme</title>
		<link>http://curtishenson.com/checkmate-20-a-free-premium-wordpress-theme/</link>
		<comments>http://curtishenson.com/checkmate-20-a-free-premium-wordpress-theme/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 23:07:10 +0000</pubDate>
		<dc:creator>Curtis Henson</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Curtis Henson]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Downloads]]></category>
		<category><![CDATA[Free Themes]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[theme]]></category>

		<guid isPermaLink="false">http://curtishenson.com/?p=392</guid>
		<description><![CDATA[Checkmate 2.0 is a popular premium WordPress theme used by people all over the world that just received a major update.  It has minimalist design based on a grid with plenty of theme options, ad management and more! ]]></description>
			<content:encoded><![CDATA[<p>Checkmate has been a very popular WordPress theme with thousands of users worldwide. Now it is has been made even better. I&#8217;ve learned a thing or two from the users of Checkmate, listened to the feature requests and I&#8217;ve decided it is time to release Checkmate 2.0.  Checkmate 2.0 is built on the original version of Checkmate, but could almost be considered a completely new theme. </p>
<p>The interface has gotten a huge and much needed update. The layout is still simple and clean but now is more polished and modern. Customizing the CSS and the look of theme is even better, the entire site was coded with the end user customizing the site in mind.</p>
<h3>Download Checkmate 2.0</h3>
<ul class="download">
<li><a href="http://demos.curtishenson.com/checkmate">View the Demo Site</a></li>
<li><a class="downloadlink" href="http://curtishenson.com/wp-content/plugins/download-monitor/download.php?id=10" title="Version2.0.4 downloaded 3675 times" >Checkmate 2.0 (3675)</a></li>
</ul>
<div class="clearfix gallery">
<a href="http://curtishenson.com/wp-content/uploads/2008/12/checkmate.png"><img src="http://curtishenson.com/wp-content/uploads/2008/12/checkmate-158x300.png" alt="checkmate" title="checkmate" width="158" height="300" class="alignleft size-medium wp-image-409" /></a><a href="http://curtishenson.com/wp-content/uploads/2008/12/a-post-with-images.png"><img src="http://curtishenson.com/wp-content/uploads/2008/12/a-post-with-images-157x300.png" alt="a-post-with-images" title="a-post-with-images" width="157" height="300" class="alignleft size-medium wp-image-413" /></a><a href="http://curtishenson.com/wp-content/uploads/2008/12/checkmate-203a-checkmate-options-2014-wordpress.png"><img src="http://curtishenson.com/wp-content/uploads/2008/12/checkmate-203a-checkmate-options-2014-wordpress-106x300.png" alt="checkmate-203a-checkmate-options-2014-wordpress" title="checkmate-203a-checkmate-options-2014-wordpress" width="106" height="300" class="alignleft size-medium wp-image-411" /></a>
</div>
<h3>Theme Options</h3>
<p>There has been a total redesign of the theme options page, and also new theme options to make <strong>customizing Checkmate even easier</strong>. Checkmate 2.0 has the ability to <strong>automatically detect uploads</strong> for CSS, logos, and backgrounds, which can easily be changed via the theme options page.</p>
<h3>Layout Options</h3>
<p>I mentioned the layout has been updated, well now it is also more flexible. Several users wanted a true <strong>3 column layout</strong>(<em>columns on each side of the content</em>), now this is possible along with a single right column, a split right column, or a combo right column. All this is controlled using theme options and widget areas, no code editing!</p>
<h3>Ad Management</h3>
<p>Ad management remains in Checkmate 2.0 unchanged. It is the same simple and flexible widget and theme options combination which gives you a quick and easy way to get ads on your theme.</p>
<h3>Support</h3>
<p>Support for Checkmate has always been a strong point and something I&#8217;ve strove to provide the best support a free theme offers. Alas WordPress comments and email aren&#8217;t the best solution, so all support will now be handled via Tender. Where you <a href="http://curtishenson.tenderapp.com"><strong>can ask questions, read documentation, and contribute to discussions</strong></a>.</p>
<h3>Features</h3>
<p>Checkmate already had a big feature list, now it is even bigger:</p>
<ul>
<li>Optional background header images controlled by theme options and uploads are automatically detected</li>
<li>User defined style sheets, easily changed and uploads are automatically detected</li>
<li>Auto detected logo controlled through theme options</li>
<li>Optional featured categories</li>
<li>Feedburner integration</li>
<li>Drop down Page menu, with theme options to control which Pages show in the menu</li>
<li>Optional footer widget areas</li>
<li>Option to use Checkmate&#8217;s previous rounded corner look</li>
<li>Ability to insert code or content into the header, after a post, or footer, without editing theme files</li>
<li>Ad management</li>
<li>Checkmate comes with 4 color themes for you to build on: grey, brown, cake, and dark.</li>
<li>Custom widgets built for Checkmate.</li>
<li>Tabbed Content Box &#8211; widget enabled</li>
<li>Two, Three, or Split Column Design</li>
<li>Feedburner Integration</li>
<li>Optional Widget enabled footer</li>
<li>Custom Icons</li>
<li>Gravatar support for authors and comments(WordPress 2.5)</li>
<li>Custom author, archive, tag, category, and search pages.</li>
<li>Widget Enabled Sidebars</li>
</ul>
<h3>Updates</h3>
<ul>
<li>Version 2.0.1</li>
<ul>
<li>Updated for WordPress 2.7</li>
<li>Threaded Comments Enabled</li>
<li>Utilizes post_class()</li>
<li>Automatically Checks for Updates</li>
</ul>
<li>Version 2.0.2</li>
<ul>
<li>Trackbacks/pingbacks style change, automatically hidden</li>
<li>Comments navigation for 2.7 fixed</li>
<li>Upgraded theme to use jQuery 1.3</li>
<li>disabled auto check for update for now due to server load</li>
</ul>
<li>Version 2.0.3</li>
<ul>
<li>Added Localization</li>
<li>Changed title structure for single post pages</li>
</ul>
<li>Version 2.0.4</li>
<ul>
<li>Converted widgets to 2.8 API</li>
<li>Fixed bugs in widgets</li>
</ul>
</ul>
<h3>License</h3>
<p>Checkmate is released under the <a href="http://creativecommons.org/licenses/by-sa/3.0/us/">Creative Commons Attribution-Share Alike 3.0</a> license.  All I ask is that you link back to my website somewhere in your site.</p>
<ul class="download">
<li><a class="downloadlink" href="http://curtishenson.com/wp-content/plugins/download-monitor/download.php?id=10" title="Version2.0.4 downloaded 3675 times" >Checkmate 2.0 (3675)</a></li>
</ul>
<h4>Really Like It?</h4>
<p>If you really like this theme and would like updates, more features, and new styles, why not grease the wheel and make a donation?<br />
<span id="msg_moreamount" class="error" style="display:none;">PayPal takes $0.35 commission for a $1 donation. Please enter at least $1.35 , thank you!</span>
	<span id="msg_noamount" class="error" style="display:none;">Please enter the amount you wish to donate and try again.</span>
	<span id="msg_activity" class="success" style="display:none;">Transferring to PayPal, please wait...</span>
		
	<form id="form_paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
	  	<input type="hidden" name="cmd" value="_donations">
	  	<input type="hidden" name="business" value="svenhenson@gmail.com">
	  	<input type="hidden" name="item_name" value="Curtis Henson Theme Donation">
	  	<input type="hidden" name="no_shipping" value="0">
	  	<input type="hidden" name="no_note" value="1">
	  	<input type="hidden" name="currency_code" value="USD">
	  	<input type="hidden" name="tax" value="0">
	  	<input type="hidden" name="bn" value="PP-DonationsBF">
	  	<label for="">Amount (US$) : </label>
		<div>
			<input type="text" name="amount" id="input_amount" width="10" class="text" />
		  	<input type="submit" name="submit" value="Donate through Paypal" class="submit" />
		</div>
	</form></p>
]]></content:encoded>
			<wfw:commentRss>http://curtishenson.com/checkmate-20-a-free-premium-wordpress-theme/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>New WordPress 2.7 Functions</title>
		<link>http://curtishenson.com/new-wordpress-27-functions/</link>
		<comments>http://curtishenson.com/new-wordpress-27-functions/#comments</comments>
		<pubDate>Sat, 22 Nov 2008 01:33:23 +0000</pubDate>
		<dc:creator>Curtis Henson</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[themes]]></category>

		<guid isPermaLink="false">http://curtishenson.com/?p=369</guid>
		<description><![CDATA[WordPress 2.7 includes a few new exciting features and functions for theme developers. I go over how to use these functions and give a few links on learning more about WordPress 2.7.]]></description>
			<content:encoded><![CDATA[<p>WordPress 2.7 is approaching us and there are some new functions for theme developers. I&#8217;m so excited, are you excited? I just can&#8217;t hide it.</p>
<h3>Easy Post Classes</h3>
<p>Something I really didn&#8217;t expect was the post_class() function. This makes the almost obligatory class=&#8221;post&#8221; a thing of the past, and replaces it with something infinitely more useful. Straight from the codex:</p>
<blockquote><p>This includes several different classes of value: post, hentry (for hAtom microformat pages), category-X (where X is the slug of every category the post is in), and tag-X (similar, but with tags). It also adds &#8220;sticky&#8221; for posts marked as sticky posts.</p></blockquote>
<p>This is great for keyword stuff&#8230;err&#8230;I mean SEO. Also it will make styling posts simple and straightforward. This is some functionality that isn&#8217;t new to some themes, but now that its part of the core, it is oh so much easier and cleaner.</p>
<h4>How to use it</h4>
<p>This one is simple enough, stick it inside the loop where you would normally have a class=&#8221;post&#8221; like so:</p>
<pre class="php" name="code">&lt;div &lt;?php post_class(); ?>></pre>
<p>Say you want to add a special class, so your posts with a certain custom field are displayed differently than a post without the custom field. Easy enough, you can pass along a single class name, space separated list, or an array of classes:</p>
<pre class="php" name="code">&lt;div &lt;?php post_class('special_class'); ?>>
&lt;div &lt;?php post_class('special_class class2 class3 class4'); ?>>
&lt;div &lt;?php post_class($my_array); ?>></pre>
<p>Great! But I want to use it outside of the loop, to display something in my sidebar on single post pages cause I&#8217;m cool like that. WordPress has got you covered there too, you can pass a post ID as a second parameter:</p>
<pre class="php" name="code">&lt;div &lt;?php post_class('', $post_id); ?>></pre>
<p>I got a feeling this is going to open up some very cool things when people start to play with it.</p>
<h3>A Logout Link</h3>
<p>OK so I think this one is relatively boring compared to the rest, but I know this will actually be useful in certain applications. It is the almighty wp_logout_url() function. It does just what you think it does, provides a <em>protected</em> log out link for your users. Use is simple just put <code>&lt;?php wp_logout_url(); ?></code> where you want it.</p>
<h3>Page Menus</h3>
<p>Another new function is actually a wrapper for wp_list_pages(). The wp_page_menu() can be used pretty much the same as wp_list_pages(), but one useful little add is the ability to a link to the homepage:</p>
<pre class="php" name="code">&lt;?php wp_page_menu('show_home=1'); ?></pre>
<h3>HTTP API</h3>
<p>There&#8217;s also a new http api for plugins that looks like it could be useful. From the codex:</p>
<blockquote><p>The HTTP API is an attempt to standardize the HTTP requests and responses for WordPress. It will eventually obsolete Snoopy and deprecate the other functions in WordPress. That is, once the HTTP API is completely stable. </p></blockquote>
<p>I haven&#8217;t got a chance to really look into any of these, but you should be aware of them as they could be a huge part of whatever plug-in you are writing.</p>
<h3>Comment Enhancements</h3>
<p>I&#8217;ve saved the best for last. WordPress 2.7 has brought some much wanted comment love, threaded, paged, etc. Themes do have support all this although, which will make some of very busy. Instead of repeating all the info about the comment updates, just head over to the <a href="http://ottodestruct.com/blog/2008/09/29/wordpress-27-comments-enhancements/">WordPress 2.7 Comments Enhancements</a> post from Otto.</p>
<h3>More&#8230;</h3>
<p>That is all I got right now, but there are more new features you may be of interest to you in WordPress 2.7. For a complete look at the features list check out the <a href="http://codex.wordpress.org/Version_2.7">codex page on WordPress 2.7</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://curtishenson.com/new-wordpress-27-functions/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
