"Sidebar Widgets" and drag and drop the widget wherever you want to show it. Changelog v.0.7 = All displayed in a single list with yearly sublists. NEW Feature: display date and/or excerpt. NEW Feature: added CSS markup to allow maximum flexibility on display. v.0.6.3 = Fixed a bug when calling get_old_posts(). v.0.6.2 = Fixed a bug when having & in post's title. Isolated repetitive code in its own function. Changes contributed by Mike Koepke. v.0.6.1 = Fixed bug when having quotes in post's title. Thanks to Mike Koepke for bug repporting and helping with fixing. v0.6 = NEW Feature: added 2 new modes, last X years and since year X. Corrected bug in $start_ago and $end_ago. v0.5.2 = XHTML valid. Luís Pérez (aka Cinéfilo) v0.5.1 = Now the $yearsago parameter works. v0.5.01 = Now the limit option works, for real ;) v0.5 = First release. I decided to start on version 0.5 because of preserving version relation with "One year ago" plugin. Thanks Thanks to Borja Fernandez, Chris Goringe and Sven Weidauer for writing their plugins and to Luis P�rez and Mike Koepke for their contributions. */ function around_this_date ( $daysbefore = '3', $daysafter = '3', $mode = '1', $yearsago = '1', $lastxyears= '1', $sinceyear='2006', $limit = '4', $none = 'none', $showdate = '0', $dateformat = 'y', $showexcerpt = '0') { $outputlist = ''; // empty the 'outputlist' string $outputlist .= ''."\n"; echo "$outputlist"; } function get_old_posts( $start_ago, $end_ago, $limit, $none, $showdate, $dateformat, $showexcerpt ) { global $wpdb; $entries = $wpdb->get_results ("SELECT " . "ID, post_title, post_date, post_excerpt, post_content " . "FROM $wpdb->posts " . " WHERE post_status = 'publish' AND (( TO_DAYS( NOW() ) - TO_DAYS( post_date ) ) BETWEEN " . $end_ago . " AND " . $start_ago . ")". " ORDER by 'asc'" . " LIMIT $limit" ); $output = ''; // empty the 'output' string $output .= ''."\n"; return "$output"; } function widget_atd_init() { if (!function_exists('register_sidebar_widget')) return; function widget_atd( $args ) { extract( $args ); $options = get_option( 'widget_atd' ); $title = $options['title']; $daysbefore = $options['daysbefore']; $daysafter = $options['daysafter']; $mode = $options['mode']; $yearsago = $options['yearsago']; $sinceyear = $options['sinceyear']; $lastxyears = $options['lastxyears']; $limit = $options['limit']; $none = $options['none']; $showdate = $options['showdate']; $dateformat = $options['dateformat']; $showexcerpt = $options['showexcerpt']; echo $before_widget . $before_title . $title . $after_title; around_this_date( $daysbefore, $daysafter, $mode, $yearsago, $lastxyears, $sinceyear, $limit, $none, $showdate, $dateformat, $showexcerpt ); echo $after_widget; } function widget_atd_control() { $options = get_option( 'widget_atd' ); if (!is_array( $options )) { $options = array( 'title' => 'This week last year...', 'daysbefore' => 3, 'daysafter' => 3, 'mode' => 1, 'yearsago' => 1, 'lastxyears' => 1, 'sinceyear' => 2005, 'limit' => 4, 'none' => 'none', 'showdate' => 0, 'dateformat' => 'y', 'showexcerpt' => 0 ); } if ($_POST['atd-submit']) { $options['title'] = strip_tags(stripslashes($_POST['atd-title'])); $options['daysbefore'] = strip_tags(stripslashes($_POST['atd-daysbefore'])); $options['daysafter'] = strip_tags(stripslashes($_POST['atd-daysafter'])); $options['mode'] = strip_tags(stripslashes($_POST['atd-mode'])); $options['yearsago'] = strip_tags(stripslashes($_POST['atd-yearsago'])); $options['sinceyear'] = strip_tags(stripslashes($_POST['atd-sinceyear'])); $options['lastxyears'] = strip_tags(stripslashes($_POST['atd-lastxyears'])); $options['limit'] = strip_tags(stripslashes($_POST['atd-limit'])); $options['none'] = strip_tags(stripslashes($_POST['atd-none'])); $options['showdate'] = strip_tags(stripslashes($_POST['atd-showdate'])); $options['dateformat'] = strip_tags(stripslashes($_POST['atd-dateformat'])); $options['showexcerpt'] = strip_tags(stripslashes($_POST['atd-showexcerpt'])); update_option( 'widget_atd', $options ); } $title = htmlspecialchars($options['title'], ENT_QUOTES); $daysbefore = htmlspecialchars($options['daysbefore'], ENT_QUOTES); $daysafter = htmlspecialchars($options['daysafter'], ENT_QUOTES); $mode = htmlspecialchars($options['mode'], ENT_QUOTES); $yearsago = htmlspecialchars($options['yearsago'], ENT_QUOTES); $sinceyear = htmlspecialchars($options['sinceyear'], ENT_QUOTES); $lastxyears = htmlspecialchars($options['lastxyears'], ENT_QUOTES); $limit = htmlspecialchars($options['limit'], ENT_QUOTES); $none = htmlspecialchars($options['none'], ENT_QUOTES); $showdate = htmlspecialchars($options['showdate'], ENT_QUOTES); $dateformat = htmlspecialchars($options['dateformat'], ENT_QUOTES); $showexcerpt = htmlspecialchars($options['showexcerpt'], ENT_QUOTES); ?>
Basic options:




Mode Options:
Advanced options:
See PHP Date manual