"Sidebar Widgets" and drag and drop the widget wherever you want to show it. Changelog 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 = 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') { if ($mode == '1') { // "classic" mode $start_ago = (365*$yearsago)+$daysbefore; $end_ago = (365*$yearsago)-$daysafter; get_old_posts( $start_ago, $end_ago, $limit, $none); } elseif ($mode == '2') { // last x years mode for($year = 1; $year <= $lastxyears; $year++) { $start_ago = (365*$year)+$daysbefore; $end_ago = (365*$year)-$daysafter; get_old_posts( $start_ago, $end_ago, $limit, $none); } } elseif ($mode == '3') { // since year x mode for($year = 1; $year <= (date("Y")-$sinceyear); $year++) { $start_ago = (365*$year)+$daysbefore; $end_ago = (365*$year)-$daysafter; get_old_posts( $start_ago, $end_ago, $limit, $none); } } } function get_old_posts( $start_ago, $end_ago, $limit, $none ) { global $wpdb; $entries = $wpdb->get_results ("SELECT " . "ID, post_title " . "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" ); print ""; } 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']; echo $before_widget . $before_title . $title . $after_title; around_this_date( $daysbefore, $daysafter, $mode, $yearsago, $lastxyears, $sinceyear, $limit, $none ); 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'); } 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'])); 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); ?>







Mode Options: