"Sidebar Widgets" and drag and drop the widget wherever you want to show it. 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 widget_atd_init() { if (!function_exists('register_sidebar_widget') || !function_exists('register_widget_control')) return; register_sidebar_widget( 'Around this date', 'widget_atd_display' ); register_widget_control( 'Around this date', 'widget_atd_control', 475, 570 ); } add_action( 'plugins_loaded', 'widget_atd_init' ); function around_this_date( $daysbefore, $daysafter, $mode, $yearsago, $lastxyears, $sinceyear, $limit, $none, $showyear, $showdate, $dateformat, $showexcerpt) { $outputlist = ''; // empty the 'outputlist' string $outputlist .= ''; echo $outputlist; } function atd_get_old_posts( $start_ago, $end_ago, $limit ) { global $wpdb; global $wp_version; $q = "SELECT ID, post_title, post_date, post_excerpt, post_content FROM $wpdb->posts "; $q .= " WHERE post_status = 'publish'"; if (version_compare($wp_version, '2.1', '>=')) $q .= " AND post_type = 'post'"; $q .= $wpdb->prepare(" AND (( TO_DAYS( NOW() ) - TO_DAYS( post_date ) ) BETWEEN %d AND %d )", $end_ago, $start_ago); $q .= " ORDER BY post_date ASC"; $q .= $wpdb->prepare(" LIMIT %d", $limit); $entries = $wpdb->get_results($q); return $entries; } function atd_format_old_posts( $entries, $year, $none, $showyear, $showdate, $dateformat, $showexcerpt ) { $output = ''; // empty the 'output' string $output .= '
  • '; if ($showyear) { $output .= $year; } $output .= ''; $output .= '
  • '; return $output; } /* Widget options */ function widget_atd_options() { $defaults = array( 'title' => 'This week last year...', 'daysbefore' => 3, 'daysafter' => 3, 'mode' => 1, 'yearsago' => 1, 'lastxyears' => 1, 'sinceyear' => 2006, 'limit' => 4, 'none' => 'none', 'showyear' => true, 'showdate' => false, 'dateformat' => 'F j', 'showexcerpt' => false ); $options = (array) get_option('widget_atd'); foreach ( $defaults as $key => $value ) if ( !isset($options[$key]) ) $options[$key] = $defaults[$key]; return $options; } function widget_atd_display( $args ) { extract( $args ); $options = widget_atd_options(); echo $before_widget . $before_title . $options['title'] . $after_title; around_this_date( $options['daysbefore'], $options['daysafter'], $options['mode'], $options['yearsago'], $options['lastxyears'], $options['sinceyear'], $options['limit'], $options['none'], $options['showyear'], $options['showdate'], $options['dateformat'], $options['showexcerpt'] ); echo $after_widget; } function widget_atd_control() { $options = $newoptions = widget_atd_options(); if ($_POST['atd-submit']) { $newoptions['title'] = strip_tags(stripslashes($_POST['atd-title'])); $newoptions['daysbefore'] = strip_tags(stripslashes($_POST['atd-daysbefore'])); $newoptions['daysafter'] = strip_tags(stripslashes($_POST['atd-daysafter'])); $newoptions['mode'] = strip_tags(stripslashes($_POST['atd-mode'])); $newoptions['yearsago'] = strip_tags(stripslashes($_POST['atd-yearsago'])); $newoptions['sinceyear'] = strip_tags(stripslashes($_POST['atd-sinceyear'])); $newoptions['lastxyears'] = strip_tags(stripslashes($_POST['atd-lastxyears'])); $newoptions['limit'] = strip_tags(stripslashes($_POST['atd-limit'])); $newoptions['none'] = strip_tags(stripslashes($_POST['atd-none'])); $newoptions['showyear'] = isset($_POST['atd-showyear']); $newoptions['showdate'] = isset($_POST['atd-showdate']); $newoptions['dateformat'] = strip_tags(stripslashes($_POST['atd-dateformat'])); $newoptions['showexcerpt'] = isset($_POST['atd-showexcerpt']); } if ( $options != $newoptions ) { $options = $newoptions; update_option('widget_atd', $options); } $title = attribute_escape($options['title']); $daysbefore = (int) $options['daysbefore']; $daysafter = (int) $options['daysafter']; $mode = (int) $options['mode']; $yearsago = (int) $options['yearsago']; $sinceyear = (int) $options['sinceyear']; $lastxyears = (int) $options['lastxyears']; $limit = (int) $options['limit']; $none = attribute_escape($options['none']); $showyear = ($options['showyear'] ? 'checked="checked"' : ''); $showdate = ($options['showdate'] ? 'checked="checked"' : ''); $dateformat = attribute_escape($options['dateformat']); $showexcerpt = ($options['showexcerpt'] ? 'checked="checked"' : ''); ?>
    Basic options:






    Mode Options:
    Advanced options:




    See PHP Date manual