Or configure it: ', $daysbefore = '3', $daysafter = '3', $mode='1', $yearsago = '1'′, $limit = '5', $none= 'none'′); ?> or ', $daysbefore = '3', $daysafter = '3', $mode='2', $lastxyears = '2'′, $limit = '5', $none= 'none'′′); ?> or ', $daysbefore = '3', $daysafter = '3', $mode='3', $sinceyear = '2004'′, $limit = '5', $none= 'none'′′); ?> License This plugin is free software; you can redistribute it and/or modify (without commercial purposes) it under the terms of the Creative Commons License (don't remove credits to author, please) You can view the full text of the license here: http://creativecommons.org/licenses/by-nc/2.5/ 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); } 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); } } 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 ""; } ?>