Top

Daily Tip: How to Show a Post From Exactly One Year Ago Today

June 6, 2010

There may be certain special occasions where you’d like to show a post from one year ago. Perhaps you’d like to dedicate a portion of your sidebar or footer to show a post from exactly one year ago. Drop this snippet anywhere in your theme’s template files where you want the post to appear:

<?php
$current_day = date('j');
$last_year = date('Y')-1;

query_posts('day='.$current_day.'&amp;year='.$last_year);

if (have_posts()):
    while (have_posts()) : the_post();

       the_title();

       the_excerpt();
    endwhile;

endif;
?>

Source: WP Recipes

Tweet This Post

Comments

Got something to say?

Bottom
Article Archive  |  This site is a historical archive of pressography.com, a WordPress plugin and theme blog that published between 2006 and 2012. It is preserved for reference and is not operated by, affiliated with, or endorsed by its original authors. Nothing here is for sale and no form on this site is active. If you are the original owner and would like this domain returned, please get in touch.