Skip to content

Instantly share code, notes, and snippets.

@folsen
Created March 30, 2010 19:13
Show Gist options
  • Save folsen/349463 to your computer and use it in GitHub Desktop.
Save folsen/349463 to your computer and use it in GitHub Desktop.
<div class="year-archive">
<h2>2006</h2>
<ul>
<?php wp_get_archives('year=2006&show_post_count=true'); ?>
</ul>
</div>
<div class="year-archive">
<h2>2007</h2>
<ul>
<?php wp_get_archives('year=2007&show_post_count=true'); ?>
</ul>
</div>
<div class="year-archive">
<h2>2008</h2>
<ul>
<?php wp_get_archives('year=2008&show_post_count=true'); ?>
</ul>
</div>
<div class="year-archive">
<h2>2009</h2>
<ul>
<?php wp_get_archives('year=2009&show_post_count=true'); ?>
</ul>
</div>
<div class="year-archive">
<h2>2010</h2>
<ul>
<?php wp_get_archives('year=2010&show_post_count=true'); ?>
</ul>
</div>
/**
* Makes the archives filterable by year
*/
function getarchives_filter($where, $args)
{
if (isset($args['year']))
{
$where .= ' AND YEAR(post_date) = ' . intval($args['year']);
}
return $where;
}
add_filter('getarchives_where', 'getarchives_filter', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment