WordPress.org

Ready to get started?Download WordPress

Forums

Archive only since a given date (3 posts)

  1. wouq
    Member
    Posted 6 years ago #

    Hi,
    I want to modify the archive widget code to have archive since a given date on. I see that parameters of "wp_get_archives" only give "limit" as an option. Is there a workaround? I'd like to display monthly archive from january 2008 to present (updated ).

    Thank you

  2. wp_guy
    Member
    Posted 6 years ago #

    Hi,

    You can do that by adding the following code to the functions.php file of your theme:

    function getarchives_since($string){
    	return $string . " AND post_date > '2008-01-01 00:00:00'";
    }
    add_filter('getarchives_where', 'getarchives_since');

    However, that will make your Archives page also show the archives since January 2008.

  3. wouq
    Member
    Posted 6 years ago #

    It works like a charm, thanks for your time!

Topic Closed

This topic has been closed to new replies.

About this Topic