views:

42

answers:

1

I am using wordpress and I am displaying my archives list in a sidebar using the function

wp_get_archives('type=monthly');

I have posts from Feb 2005 to April 2010 but I want to display June 2009 onwards links. (i.e. june 2009, july 2009, ....april 2010).

How do I prevent Feb 2005 - may 2005 from being displayed in the archives list.

(Please don't suggest adding a limit i.e. wp_get_archives('type=daily&limit=15'); . That will not solve my problem)

+1  A: 
$args = array(
    'type'            => 'monthly',
    'format'          => 'custom', 
    'show_post_count' => true,
    'echo'            => 0 ); 
$resulthtml = wp_get_archives($args); 
$links_to_archives = array_map('trim', explode("\n", $resulthtml));
$string_in_first_archive_not_wanted = 'May 2005';

// wp_get_archives works in reverse order
print "<ul>";
foreach($links_to_archives as $link) {
    // once we hit 'May 2005' we don't print anything more
    if (strpos($link, $string_in_first_archive_not_wanted) > 0) { 
        break;
    } else {
        print "<li>" . $link . "</li>";
    }
}
print "</ul>";
artlung