<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Curtis Henson</title>
	
	<link>http://curtishenson.com</link>
	<description>Freelance Web Designer and Wordpress Guru</description>
	<lastBuildDate>Tue, 28 Jul 2009 02:55:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/curtishenson" type="application/rss+xml" /><feedburner:emailServiceId>curtishenson</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcurtishenson" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcurtishenson" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcurtishenson" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/curtishenson" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcurtishenson" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fcurtishenson" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcurtishenson" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Creating a Chart on Your WordPress Archives Page</title>
		<link>http://feedproxy.google.com/~r/curtishenson/~3/CD8nYP5ubbA/</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.


Related posts:<ol><li><a href='http://curtishenson.com/dynamic-multi-level-page-menus-in-wordpress/' rel='bookmark' title='Permanent Link: Dynamic Multi-level Page Menus in WordPress'>Dynamic Multi-level Page Menus in WordPress</a> <small>Something I often see while trolling boards (and engaging in...</small></li><li><a href='http://curtishenson.com/wordpress-posts-navigation-quick-tip/' rel='bookmark' title='Permanent Link: WordPress Posts Navigation Quick Tip'>WordPress Posts Navigation Quick Tip</a> <small> Say you want to use the next_posts_link() and previous_posts_link()...</small></li><li><a href='http://curtishenson.com/new-wordpress-27-functions/' rel='bookmark' title='Permanent Link: New WordPress 2.7 Functions'>New WordPress 2.7 Functions</a> <small>WordPress 2.7 includes a few new exciting features and functions...</small></li></ol>]]></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>


<p>Related posts:<ol><li><a href='http://curtishenson.com/dynamic-multi-level-page-menus-in-wordpress/' rel='bookmark' title='Permanent Link: Dynamic Multi-level Page Menus in WordPress'>Dynamic Multi-level Page Menus in WordPress</a> <small>Something I often see while trolling boards (and engaging in...</small></li><li><a href='http://curtishenson.com/wordpress-posts-navigation-quick-tip/' rel='bookmark' title='Permanent Link: WordPress Posts Navigation Quick Tip'>WordPress Posts Navigation Quick Tip</a> <small> Say you want to use the next_posts_link() and previous_posts_link()...</small></li><li><a href='http://curtishenson.com/new-wordpress-27-functions/' rel='bookmark' title='Permanent Link: New WordPress 2.7 Functions'>New WordPress 2.7 Functions</a> <small>WordPress 2.7 includes a few new exciting features and functions...</small></li></ol></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/curtishenson?a=CD8nYP5ubbA:2H-FmVkAaCk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/curtishenson?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/curtishenson?a=CD8nYP5ubbA:2H-FmVkAaCk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/curtishenson?i=CD8nYP5ubbA:2H-FmVkAaCk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/curtishenson?a=CD8nYP5ubbA:2H-FmVkAaCk:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/curtishenson?i=CD8nYP5ubbA:2H-FmVkAaCk:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/curtishenson/~4/CD8nYP5ubbA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://curtishenson.com/creating-a-chart-on-your-wordpress-archives-page/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://curtishenson.com/creating-a-chart-on-your-wordpress-archives-page/</feedburner:origLink></item>
		<item>
		<title>Tender Quietly Adds Killer Little Feature</title>
		<link>http://feedproxy.google.com/~r/curtishenson/~3/hrbgufYyLDo/</link>
		<comments>http://curtishenson.com/tender-quietly-adds-killer-little-feature/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 23:07:30 +0000</pubDate>
		<dc:creator>Curtis Henson</dc:creator>
				<category><![CDATA[Extras]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[users]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[widgets]]></category>

		<guid isPermaLink="false">http://curtishenson.com/?p=618</guid>
		<description><![CDATA[Tender just rolled out a new javascript widget which allows you to insert a form into your site which will post straight to Tender.  The widget even provides links to documentation, and the creation of a user account for the person.  All this without the user having to leave your site, I&#8217;ll be [...]


Related posts:<ol><li><a href='http://curtishenson.com/checkmate-20-a-free-premium-wordpress-theme/' rel='bookmark' title='Permanent Link: Checkmate 2.0: A Free Premium WordPress Theme'>Checkmate 2.0: A Free Premium WordPress Theme</a> <small>Checkmate 2.0 is a popular premium WordPress theme used by...</small></li><li><a href='http://curtishenson.com/checkmate-20-feature-set/' rel='bookmark' title='Permanent Link: Checkmate 2.0 Feature Set'>Checkmate 2.0 Feature Set</a> <small>The feature set for Checkmate 2.0 has been set, and...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://tenderapp.com/">Tender</a> just rolled out a new javascript widget which allows you to insert a form into your site which will post straight to Tender.  The widget even provides links to documentation, and the creation of a user account for the person.  All this without the user having to leave your site, I&#8217;ll be integrating it here soon.  So right now you probably have two questions: <strong>What is Tender?</strong> and <strong>Why Do I Care?</strong></p>
<h4>What is Tender?</h4>
<p>It&#8217;s a support web app, I know sounds boring, and it is to be honest. But some of us have to deal with supporting things. <a href="http://tenderapp.com/">Tender</a> makes this incredibly easy and painless. <img src="http://curtishenson.com/wp-content/uploads/2009/06/tender_widget.jpg" alt="tender_widget" title="tender_widget" width="470" height="426" class="alignright size-full wp-image-620 push-6" /> Tender has some features which set it apart for me. Numeral uno is I can manage support requests from email, I hardly ever have to actually log into the website.  Second is the integration with <a href="http://lighthouseapp.com">Lighthouse</a>, my ticket tracking app of choice.  When I first released Checkmate I encouraged people to post tickets to <a href="http://curtishenson.lighthouseapp.com">my lighthouse</a>, it was a massive failure.  However <a href="https://curtishenson.tenderapp.com/">my Tender</a> has been a success and has made responding to support requests much less painful.</p>
<h4>Why Do I Care?</h4>
<p>If you don&#8217;t support any software or services you don&#8217;t care, you shouldn&#8217;t care, and you should be happy you don&#8217;t deal with it. If you do, OR you <strong>SHOULD</strong> be supporting something(<em>*cough* your WordPress themes *cough*</em>) then you should care. Tender is an efficient, user friendly way to offer quality support. And this new widget is just an example of their commitment to making things easy for the users, who are the most important part of your software/service.</p>


<p>Related posts:<ol><li><a href='http://curtishenson.com/checkmate-20-a-free-premium-wordpress-theme/' rel='bookmark' title='Permanent Link: Checkmate 2.0: A Free Premium WordPress Theme'>Checkmate 2.0: A Free Premium WordPress Theme</a> <small>Checkmate 2.0 is a popular premium WordPress theme used by...</small></li><li><a href='http://curtishenson.com/checkmate-20-feature-set/' rel='bookmark' title='Permanent Link: Checkmate 2.0 Feature Set'>Checkmate 2.0 Feature Set</a> <small>The feature set for Checkmate 2.0 has been set, and...</small></li></ol></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/curtishenson?a=hrbgufYyLDo:YIy4AL2xQWg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/curtishenson?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/curtishenson?a=hrbgufYyLDo:YIy4AL2xQWg:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/curtishenson?i=hrbgufYyLDo:YIy4AL2xQWg:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/curtishenson?a=hrbgufYyLDo:YIy4AL2xQWg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/curtishenson?i=hrbgufYyLDo:YIy4AL2xQWg:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/curtishenson/~4/hrbgufYyLDo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://curtishenson.com/tender-quietly-adds-killer-little-feature/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://curtishenson.com/tender-quietly-adds-killer-little-feature/</feedburner:origLink></item>
		<item>
		<title>Quick Tip: Delay Page Loading with jQuery</title>
		<link>http://feedproxy.google.com/~r/curtishenson/~3/XocC2fPOfPQ/</link>
		<comments>http://curtishenson.com/quick-tip-delay-page-loading-with-jquery/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 01:15:07 +0000</pubDate>
		<dc:creator>Curtis Henson</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://curtishenson.com/?p=521</guid>
		<description><![CDATA[On a site I recently worked on I wanted to have an animation before the next page loaded. What I wanted to happen was: user clicks a link, animation plays out, page is loaded normally. It is a nice little effect, but this is probably a trick you want to use sparingly...please...use it sparingly.


Related posts:<ol><li><a href='http://curtishenson.com/wordpress-posts-navigation-quick-tip/' rel='bookmark' title='Permanent Link: WordPress Posts Navigation Quick Tip'>WordPress Posts Navigation Quick Tip</a> <small> Say you want to use the next_posts_link() and previous_posts_link()...</small></li><li><a href='http://curtishenson.com/separating-and-hiding-trackbacks-with-jquery-in-wordpress-27/' rel='bookmark' title='Permanent Link: Separating and Hiding Trackbacks with Jquery in WordPress 2.7'>Separating and Hiding Trackbacks with Jquery in WordPress 2.7</a> <small>If you're designing and coding themes for WordPress, please, I...</small></li><li><a href='http://curtishenson.com/dynamic-multi-level-page-menus-in-wordpress/' rel='bookmark' title='Permanent Link: Dynamic Multi-level Page Menus in WordPress'>Dynamic Multi-level Page Menus in WordPress</a> <small>Something I often see while trolling boards (and engaging in...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>On a site I recently worked on I wanted to have an animation before the next page loaded. What I wanted to happen was: user clicks a link, animation plays out, page is loaded normally. It is a nice little effect, but this is probably a trick you want to use sparingly&#8230;please&#8230;use it sparingly.</p>
<p>This uses the <a href="http://www.evanbot.com/article/jquery-delay-plugin/4">delay</a>, and <a href="http://gsgd.co.uk/sandbox/jquery/easing/">easing</a> plugins for jquery. The below example includes the animation just as an example.</p>
<pre name="code" class="js">
$('#link').click(function(){
        // Get the url of the link
		var toLoad = $(this).attr('href');

			// Do some stuff
			$(this).animate({
				marginRight: '50px',
				marginLeft: '-175px'
			}, 300, 'easeOutSine').animate({
				marginRight: '-38px',
				marginLeft: '-120px'
			}, 500, 'easeOutBounce');
			// Stop doing stuff

        // Wait 700ms before loading the url
		$(this).delay(700, function(){
			window.location = toLoad;
		});

        // Don't let the link do its natural thing
		return false;
});
</pre>


<p>Related posts:<ol><li><a href='http://curtishenson.com/wordpress-posts-navigation-quick-tip/' rel='bookmark' title='Permanent Link: WordPress Posts Navigation Quick Tip'>WordPress Posts Navigation Quick Tip</a> <small> Say you want to use the next_posts_link() and previous_posts_link()...</small></li><li><a href='http://curtishenson.com/separating-and-hiding-trackbacks-with-jquery-in-wordpress-27/' rel='bookmark' title='Permanent Link: Separating and Hiding Trackbacks with Jquery in WordPress 2.7'>Separating and Hiding Trackbacks with Jquery in WordPress 2.7</a> <small>If you're designing and coding themes for WordPress, please, I...</small></li><li><a href='http://curtishenson.com/dynamic-multi-level-page-menus-in-wordpress/' rel='bookmark' title='Permanent Link: Dynamic Multi-level Page Menus in WordPress'>Dynamic Multi-level Page Menus in WordPress</a> <small>Something I often see while trolling boards (and engaging in...</small></li></ol></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/curtishenson?a=XocC2fPOfPQ:6dhRbVaeS1E:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/curtishenson?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/curtishenson?a=XocC2fPOfPQ:6dhRbVaeS1E:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/curtishenson?i=XocC2fPOfPQ:6dhRbVaeS1E:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/curtishenson?a=XocC2fPOfPQ:6dhRbVaeS1E:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/curtishenson?i=XocC2fPOfPQ:6dhRbVaeS1E:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/curtishenson/~4/XocC2fPOfPQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://curtishenson.com/quick-tip-delay-page-loading-with-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://curtishenson.com/quick-tip-delay-page-loading-with-jquery/</feedburner:origLink></item>
		<item>
		<title>Press75 Releases Two New Plugins</title>
		<link>http://feedproxy.google.com/~r/curtishenson/~3/v2E8hDDqZNw/</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[Extras]]></category>
		<category><![CDATA[Links]]></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.


Related posts:<ol><li><a href='http://curtishenson.com/checkmate-20-a-free-premium-wordpress-theme/' rel='bookmark' title='Permanent Link: Checkmate 2.0: A Free Premium WordPress Theme'>Checkmate 2.0: A Free Premium WordPress Theme</a> <small>Checkmate 2.0 is a popular premium WordPress theme used by...</small></li><li><a href='http://curtishenson.com/new-wordpress-27-functions/' rel='bookmark' title='Permanent Link: New WordPress 2.7 Functions'>New WordPress 2.7 Functions</a> <small>WordPress 2.7 includes a few new exciting features and functions...</small></li><li><a href='http://curtishenson.com/dry-wordpress-theme-coding/' rel='bookmark' title='Permanent Link: DRY WordPress Theme Coding'>DRY WordPress Theme Coding</a> <small>Don't Repeat Yourself is the rule, the name of the...</small></li></ol>]]></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 Encoder</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 Encoder</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>


<p>Related posts:<ol><li><a href='http://curtishenson.com/checkmate-20-a-free-premium-wordpress-theme/' rel='bookmark' title='Permanent Link: Checkmate 2.0: A Free Premium WordPress Theme'>Checkmate 2.0: A Free Premium WordPress Theme</a> <small>Checkmate 2.0 is a popular premium WordPress theme used by...</small></li><li><a href='http://curtishenson.com/new-wordpress-27-functions/' rel='bookmark' title='Permanent Link: New WordPress 2.7 Functions'>New WordPress 2.7 Functions</a> <small>WordPress 2.7 includes a few new exciting features and functions...</small></li><li><a href='http://curtishenson.com/dry-wordpress-theme-coding/' rel='bookmark' title='Permanent Link: DRY WordPress Theme Coding'>DRY WordPress Theme Coding</a> <small>Don't Repeat Yourself is the rule, the name of the...</small></li></ol></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/curtishenson?a=v2E8hDDqZNw:a_yWE_y0q8w:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/curtishenson?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/curtishenson?a=v2E8hDDqZNw:a_yWE_y0q8w:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/curtishenson?i=v2E8hDDqZNw:a_yWE_y0q8w:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/curtishenson?a=v2E8hDDqZNw:a_yWE_y0q8w:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/curtishenson?i=v2E8hDDqZNw:a_yWE_y0q8w:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/curtishenson/~4/v2E8hDDqZNw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://curtishenson.com/press75-releases-two-new-plugins/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
<enclosure url="http://www.press75.com/docs/simple-post-thumbnails/simple-post-thumbnails.mp4" length="13632118" type="video/mp4" />
		<feedburner:origLink>http://curtishenson.com/press75-releases-two-new-plugins/</feedburner:origLink></item>
		<item>
		<title>DRY WordPress Theme Coding</title>
		<link>http://feedproxy.google.com/~r/curtishenson/~3/oSniCpOA2RQ/</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.  


Related posts:<ol><li><a href='http://curtishenson.com/wordpress-theme-tools-project-announcement/' rel='bookmark' title='Permanent Link: WordPress Theme Tools Project Announcement'>WordPress Theme Tools Project Announcement</a> <small>A new project for WordPress theme developers which will make...</small></li><li><a href='http://curtishenson.com/wordpress-navigation-helper-function-comments-and-posts/' rel='bookmark' title='Permanent Link: WordPress Navigation Helper Function, Comments and Posts'>WordPress Navigation Helper Function, Comments and Posts</a> <small>A quick tip on only displaying navigation blocks when there...</small></li><li><a href='http://curtishenson.com/dynamic-multi-level-page-menus-in-wordpress/' rel='bookmark' title='Permanent Link: Dynamic Multi-level Page Menus in WordPress'>Dynamic Multi-level Page Menus in WordPress</a> <small>Something I often see while trolling boards (and engaging in...</small></li></ol>]]></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</h3>
<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>


<p>Related posts:<ol><li><a href='http://curtishenson.com/wordpress-theme-tools-project-announcement/' rel='bookmark' title='Permanent Link: WordPress Theme Tools Project Announcement'>WordPress Theme Tools Project Announcement</a> <small>A new project for WordPress theme developers which will make...</small></li><li><a href='http://curtishenson.com/wordpress-navigation-helper-function-comments-and-posts/' rel='bookmark' title='Permanent Link: WordPress Navigation Helper Function, Comments and Posts'>WordPress Navigation Helper Function, Comments and Posts</a> <small>A quick tip on only displaying navigation blocks when there...</small></li><li><a href='http://curtishenson.com/dynamic-multi-level-page-menus-in-wordpress/' rel='bookmark' title='Permanent Link: Dynamic Multi-level Page Menus in WordPress'>Dynamic Multi-level Page Menus in WordPress</a> <small>Something I often see while trolling boards (and engaging in...</small></li></ol></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/curtishenson?a=oSniCpOA2RQ:cKOhcIPLk7Y:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/curtishenson?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/curtishenson?a=oSniCpOA2RQ:cKOhcIPLk7Y:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/curtishenson?i=oSniCpOA2RQ:cKOhcIPLk7Y:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/curtishenson?a=oSniCpOA2RQ:cKOhcIPLk7Y:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/curtishenson?i=oSniCpOA2RQ:cKOhcIPLk7Y:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/curtishenson/~4/oSniCpOA2RQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://curtishenson.com/dry-wordpress-theme-coding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://curtishenson.com/dry-wordpress-theme-coding/</feedburner:origLink></item>
		<item>
		<title>Dynamic Multi-level Page Menus in WordPress</title>
		<link>http://feedproxy.google.com/~r/curtishenson/~3/fYM4PPI7QE8/</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>".


Related posts:<ol><li><a href='http://curtishenson.com/creating-a-chart-on-your-wordpress-archives-page/' rel='bookmark' title='Permanent Link: Creating a Chart on Your WordPress Archives Page'>Creating a Chart on Your WordPress Archives Page</a> <small>One part of WordPress that I've never been overly impressed...</small></li><li><a href='http://curtishenson.com/wordpress-navigation-helper-function-comments-and-posts/' rel='bookmark' title='Permanent Link: WordPress Navigation Helper Function, Comments and Posts'>WordPress Navigation Helper Function, Comments and Posts</a> <small>A quick tip on only displaying navigation blocks when there...</small></li><li><a href='http://curtishenson.com/new-wordpress-27-functions/' rel='bookmark' title='Permanent Link: New WordPress 2.7 Functions'>New WordPress 2.7 Functions</a> <small>WordPress 2.7 includes a few new exciting features and functions...</small></li></ol>]]></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>


<p>Related posts:<ol><li><a href='http://curtishenson.com/creating-a-chart-on-your-wordpress-archives-page/' rel='bookmark' title='Permanent Link: Creating a Chart on Your WordPress Archives Page'>Creating a Chart on Your WordPress Archives Page</a> <small>One part of WordPress that I've never been overly impressed...</small></li><li><a href='http://curtishenson.com/wordpress-navigation-helper-function-comments-and-posts/' rel='bookmark' title='Permanent Link: WordPress Navigation Helper Function, Comments and Posts'>WordPress Navigation Helper Function, Comments and Posts</a> <small>A quick tip on only displaying navigation blocks when there...</small></li><li><a href='http://curtishenson.com/new-wordpress-27-functions/' rel='bookmark' title='Permanent Link: New WordPress 2.7 Functions'>New WordPress 2.7 Functions</a> <small>WordPress 2.7 includes a few new exciting features and functions...</small></li></ol></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/curtishenson?a=gdjjDvMB"><img src="http://feeds.feedburner.com/~f/curtishenson?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/curtishenson?a=8GQfzH1v"><img src="http://feeds.feedburner.com/~f/curtishenson?i=8GQfzH1v" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/curtishenson?a=lPVIwnPE"><img src="http://feeds.feedburner.com/~f/curtishenson?i=lPVIwnPE" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/curtishenson/~4/fYM4PPI7QE8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://curtishenson.com/dynamic-multi-level-page-menus-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		<feedburner:origLink>http://curtishenson.com/dynamic-multi-level-page-menus-in-wordpress/</feedburner:origLink></item>
		<item>
		<title>WordPress Navigation Helper Function, Comments and Posts</title>
		<link>http://feedproxy.google.com/~r/curtishenson/~3/yM0fEU599Tw/</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.


Related posts:<ol><li><a href='http://curtishenson.com/wordpress-posts-navigation-quick-tip/' rel='bookmark' title='Permanent Link: WordPress Posts Navigation Quick Tip'>WordPress Posts Navigation Quick Tip</a> <small> Say you want to use the next_posts_link() and previous_posts_link()...</small></li><li><a href='http://curtishenson.com/get-more-design-control-over-wordpress-27-comments/' rel='bookmark' title='Permanent Link: Get More Design Control Over WordPress 2.7 Comments'>Get More Design Control Over WordPress 2.7 Comments</a> <small>So you got this awesome design all ready for WordPress...</small></li><li><a href='http://curtishenson.com/dry-wordpress-theme-coding/' rel='bookmark' title='Permanent Link: DRY WordPress Theme Coding'>DRY WordPress Theme Coding</a> <small>Don't Repeat Yourself is the rule, the name of the...</small></li></ol>]]></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>


<p>Related posts:<ol><li><a href='http://curtishenson.com/wordpress-posts-navigation-quick-tip/' rel='bookmark' title='Permanent Link: WordPress Posts Navigation Quick Tip'>WordPress Posts Navigation Quick Tip</a> <small> Say you want to use the next_posts_link() and previous_posts_link()...</small></li><li><a href='http://curtishenson.com/get-more-design-control-over-wordpress-27-comments/' rel='bookmark' title='Permanent Link: Get More Design Control Over WordPress 2.7 Comments'>Get More Design Control Over WordPress 2.7 Comments</a> <small>So you got this awesome design all ready for WordPress...</small></li><li><a href='http://curtishenson.com/dry-wordpress-theme-coding/' rel='bookmark' title='Permanent Link: DRY WordPress Theme Coding'>DRY WordPress Theme Coding</a> <small>Don't Repeat Yourself is the rule, the name of the...</small></li></ol></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/curtishenson?a=KacVMcfB"><img src="http://feeds.feedburner.com/~f/curtishenson?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/curtishenson?a=pwamaxAJ"><img src="http://feeds.feedburner.com/~f/curtishenson?i=pwamaxAJ" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/curtishenson?a=MV8DU4nh"><img src="http://feeds.feedburner.com/~f/curtishenson?i=MV8DU4nh" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/curtishenson/~4/yM0fEU599Tw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://curtishenson.com/wordpress-navigation-helper-function-comments-and-posts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://curtishenson.com/wordpress-navigation-helper-function-comments-and-posts/</feedburner:origLink></item>
		<item>
		<title>WordPress Theme Tools Project Announcement</title>
		<link>http://feedproxy.google.com/~r/curtishenson/~3/KjRjwvri3iM/</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.


Related posts:<ol><li><a href='http://curtishenson.com/dry-wordpress-theme-coding/' rel='bookmark' title='Permanent Link: DRY WordPress Theme Coding'>DRY WordPress Theme Coding</a> <small>Don't Repeat Yourself is the rule, the name of the...</small></li><li><a href='http://curtishenson.com/wordpress-navigation-helper-function-comments-and-posts/' rel='bookmark' title='Permanent Link: WordPress Navigation Helper Function, Comments and Posts'>WordPress Navigation Helper Function, Comments and Posts</a> <small>A quick tip on only displaying navigation blocks when there...</small></li><li><a href='http://curtishenson.com/checkmate-20-a-free-premium-wordpress-theme/' rel='bookmark' title='Permanent Link: Checkmate 2.0: A Free Premium WordPress Theme'>Checkmate 2.0: A Free Premium WordPress Theme</a> <small>Checkmate 2.0 is a popular premium WordPress theme used by...</small></li></ol>]]></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>


<p>Related posts:<ol><li><a href='http://curtishenson.com/dry-wordpress-theme-coding/' rel='bookmark' title='Permanent Link: DRY WordPress Theme Coding'>DRY WordPress Theme Coding</a> <small>Don't Repeat Yourself is the rule, the name of the...</small></li><li><a href='http://curtishenson.com/wordpress-navigation-helper-function-comments-and-posts/' rel='bookmark' title='Permanent Link: WordPress Navigation Helper Function, Comments and Posts'>WordPress Navigation Helper Function, Comments and Posts</a> <small>A quick tip on only displaying navigation blocks when there...</small></li><li><a href='http://curtishenson.com/checkmate-20-a-free-premium-wordpress-theme/' rel='bookmark' title='Permanent Link: Checkmate 2.0: A Free Premium WordPress Theme'>Checkmate 2.0: A Free Premium WordPress Theme</a> <small>Checkmate 2.0 is a popular premium WordPress theme used by...</small></li></ol></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/curtishenson?a=Of6cJXio"><img src="http://feeds.feedburner.com/~f/curtishenson?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/curtishenson?a=U67oUQ2y"><img src="http://feeds.feedburner.com/~f/curtishenson?i=U67oUQ2y" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/curtishenson?a=UYB970Bd"><img src="http://feeds.feedburner.com/~f/curtishenson?i=UYB970Bd" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/curtishenson/~4/KjRjwvri3iM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://curtishenson.com/wordpress-theme-tools-project-announcement/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://curtishenson.com/wordpress-theme-tools-project-announcement/</feedburner:origLink></item>
		<item>
		<title>Get More Design Control Over WordPress 2.7 Comments</title>
		<link>http://feedproxy.google.com/~r/curtishenson/~3/SeYy-2oBxFg/</link>
		<comments>http://curtishenson.com/get-more-design-control-over-wordpress-27-comments/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 00:43:05 +0000</pubDate>
		<dc:creator>Curtis Henson</dc:creator>
				<category><![CDATA[Links]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://curtishenson.com/?p=448</guid>
		<description><![CDATA[So you got this awesome design all ready for WordPress 2.7, you even got how those pesky threaded comments planned out <strong>perfect</strong>! Oops, didn't you know? WordPress' comment function well, not lacking for a better term, sucks...<em>a lot</em>. It'll probably get better in the future, but what to do right now? Bend them to your will, no mercy.


Related posts:<ol><li><a href='http://curtishenson.com/wordpress-navigation-helper-function-comments-and-posts/' rel='bookmark' title='Permanent Link: WordPress Navigation Helper Function, Comments and Posts'>WordPress Navigation Helper Function, Comments and Posts</a> <small>A quick tip on only displaying navigation blocks when there...</small></li><li><a href='http://curtishenson.com/separating-and-hiding-trackbacks-with-jquery-in-wordpress-27/' rel='bookmark' title='Permanent Link: Separating and Hiding Trackbacks with Jquery in WordPress 2.7'>Separating and Hiding Trackbacks with Jquery in WordPress 2.7</a> <small>If you're designing and coding themes for WordPress, please, I...</small></li><li><a href='http://curtishenson.com/dry-wordpress-theme-coding/' rel='bookmark' title='Permanent Link: DRY WordPress Theme Coding'>DRY WordPress Theme Coding</a> <small>Don't Repeat Yourself is the rule, the name of the...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>So you got this awesome design all ready for WordPress 2.7, you even got how those pesky threaded comments planned out <strong>perfect</strong>! Oops, didn&#8217;t you know? WordPress&#8217; comment function well, not lacking for a better term, sucks&#8230;<em>a lot</em>. It&#8217;ll probably get better in the future, but what to do right now? Bend them to your will, no mercy. That is what <strong>Chad Coleman</strong> has done, and thank God it was him and not me. </p>
<p>Go read his article <a href="http://c.hadcoleman.com/2009/01/comment-design-for-wordpress-27/">Comment Design For WordPress 2.7</a></p>


<p>Related posts:<ol><li><a href='http://curtishenson.com/wordpress-navigation-helper-function-comments-and-posts/' rel='bookmark' title='Permanent Link: WordPress Navigation Helper Function, Comments and Posts'>WordPress Navigation Helper Function, Comments and Posts</a> <small>A quick tip on only displaying navigation blocks when there...</small></li><li><a href='http://curtishenson.com/separating-and-hiding-trackbacks-with-jquery-in-wordpress-27/' rel='bookmark' title='Permanent Link: Separating and Hiding Trackbacks with Jquery in WordPress 2.7'>Separating and Hiding Trackbacks with Jquery in WordPress 2.7</a> <small>If you're designing and coding themes for WordPress, please, I...</small></li><li><a href='http://curtishenson.com/dry-wordpress-theme-coding/' rel='bookmark' title='Permanent Link: DRY WordPress Theme Coding'>DRY WordPress Theme Coding</a> <small>Don't Repeat Yourself is the rule, the name of the...</small></li></ol></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/curtishenson?a=tfm0AhpF"><img src="http://feeds.feedburner.com/~f/curtishenson?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/curtishenson?a=E9FmKC09"><img src="http://feeds.feedburner.com/~f/curtishenson?i=E9FmKC09" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/curtishenson?a=M1SVjFpm"><img src="http://feeds.feedburner.com/~f/curtishenson?i=M1SVjFpm" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/curtishenson/~4/SeYy-2oBxFg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://curtishenson.com/get-more-design-control-over-wordpress-27-comments/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://curtishenson.com/get-more-design-control-over-wordpress-27-comments/</feedburner:origLink></item>
		<item>
		<title>Separating and Hiding Trackbacks with Jquery in WordPress 2.7</title>
		<link>http://feedproxy.google.com/~r/curtishenson/~3/pvbLEZrs0BM/</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.


Related posts:<ol><li><a href='http://curtishenson.com/wordpress-navigation-helper-function-comments-and-posts/' rel='bookmark' title='Permanent Link: WordPress Navigation Helper Function, Comments and Posts'>WordPress Navigation Helper Function, Comments and Posts</a> <small>A quick tip on only displaying navigation blocks when there...</small></li><li><a href='http://curtishenson.com/get-more-design-control-over-wordpress-27-comments/' rel='bookmark' title='Permanent Link: Get More Design Control Over WordPress 2.7 Comments'>Get More Design Control Over WordPress 2.7 Comments</a> <small>So you got this awesome design all ready for WordPress...</small></li><li><a href='http://curtishenson.com/creating-a-chart-on-your-wordpress-archives-page/' rel='bookmark' title='Permanent Link: Creating a Chart on Your WordPress Archives Page'>Creating a Chart on Your WordPress Archives Page</a> <small>One part of WordPress that I've never been overly impressed...</small></li></ol>]]></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 &#8217;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>


<p>Related posts:<ol><li><a href='http://curtishenson.com/wordpress-navigation-helper-function-comments-and-posts/' rel='bookmark' title='Permanent Link: WordPress Navigation Helper Function, Comments and Posts'>WordPress Navigation Helper Function, Comments and Posts</a> <small>A quick tip on only displaying navigation blocks when there...</small></li><li><a href='http://curtishenson.com/get-more-design-control-over-wordpress-27-comments/' rel='bookmark' title='Permanent Link: Get More Design Control Over WordPress 2.7 Comments'>Get More Design Control Over WordPress 2.7 Comments</a> <small>So you got this awesome design all ready for WordPress...</small></li><li><a href='http://curtishenson.com/creating-a-chart-on-your-wordpress-archives-page/' rel='bookmark' title='Permanent Link: Creating a Chart on Your WordPress Archives Page'>Creating a Chart on Your WordPress Archives Page</a> <small>One part of WordPress that I've never been overly impressed...</small></li></ol></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/curtishenson?a=NaQ02Hlk"><img src="http://feeds.feedburner.com/~f/curtishenson?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/curtishenson?a=Ev25Vc1e"><img src="http://feeds.feedburner.com/~f/curtishenson?i=Ev25Vc1e" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/curtishenson?a=t01DoSN1"><img src="http://feeds.feedburner.com/~f/curtishenson?i=t01DoSN1" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/curtishenson/~4/pvbLEZrs0BM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://curtishenson.com/separating-and-hiding-trackbacks-with-jquery-in-wordpress-27/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		<feedburner:origLink>http://curtishenson.com/separating-and-hiding-trackbacks-with-jquery-in-wordpress-27/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 0.876 seconds. --><!-- Cached page generated by WP-Super-Cache on 2009-11-03 00:20:30 -->
