posts; //get home url for base of link $info = get_bloginfo('url'); $info = apply_filters('bloginfo', $info); $homeurl = convert_chars($info); $m = ''; if (isset($_GET['m'])) { $m = $_GET['m']; } if (isset($_GET['year'])) { $m = $_GET['year']; } if (isset($_GET['monthnum'])) { $m .= $_GET['monthnum']; } if (isset($_GET['day'])) { $m .= $_GET['day']; } if ($m != '') { switch(strlen($m)) { case 4: //archive is year $m = (int)$m; $past = $wpdb->get_row("SELECT post_date, YEAR(post_date) as year FROM $tableposts WHERE YEAR(post_date) < '".$m."'AND post_status = 'publish' ORDER BY post_date DESC"); if ($past) { echo $before."year)."\">".$past->year."".$after; } break; case 6: //archive is month $thisYear = substr($m, 0, 4); $thisMonth = substr($m, 4, 2); if (substr($thisMonth,0,1) == '0') { $thisMonth = substr($m, 5, 1); } $thisMonth = (int)$thisMonth; $thisYear = (int)$thisYear; $timestamp = mktime(0, 0, 0, $thisMonth, 1, $thisYear); $currentdate = date("Y-m-d G:i:s", $timestamp); //echo $currentdate; $past = $wpdb->get_row("SELECT post_date, YEAR(post_date) as year, MONTH(post_date) as month FROM $tableposts WHERE post_date < '".$currentdate."' AND post_status = 'publish' ORDER BY post_date DESC"); $timestampfordisplay = mktime(0,0,0,$past->month,1,$past->year); $forDisplay = __(date("F", $timestampfordisplay)); $forDisplay .= " ".date("Y", $timestampfordisplay); if ($past) { echo $before."year,$past->month)."\">".$forDisplay."".$after; } break; case 8: //archive is day YYYYMMDD $thisYear = substr($m, 0, 4); $thisMonth = substr($m, 4, 2); $thisDay = substr($m, 6, 2); if (substr($thisDay,0,1) == '0') { $thisDay = substr($m, 7, 1); } if (substr($thisMonth,0,1) == '0') { $thisMonth = substr($m, 5, 1); } $thisDay = (int)$thisDay; $thisMonth = (int)$thisMonth; $thisYear = (int)$thisYear; $timestamp = mktime(0, 0, 0, $thisMonth, $thisDay, $thisYear); $currentdate = date("Y-m-d G:i:s", $timestamp); //echo $currentdate; $past = $wpdb->get_row("SELECT post_date, YEAR(post_date) as year, MONTH(post_date) as month, DAYOFMONTH(post_date) as day FROM $tableposts WHERE post_date < '".$currentdate."' ORDER BY post_date DESC"); $timestampfordisplay = mktime(0,0,0,$past->month,$past->day,$past->year); $forDisplay = __(date("F", $timestampfordisplay)); $forDisplay .= " ".date("j, Y", $timestampfordisplay); if ($past) { echo $before."year,$past->month,$past->day)."\">".$forDisplay."".$after; } break; } } } function next_archive_date($before='', $after='') { global $wpdb, $tableposts; if (!isset($tableposts)) $tableposts = $wpdb->posts; //get home url for base of link $info = get_bloginfo('url'); $info = apply_filters('bloginfo', $info); $homeurl = convert_chars($info); $m = ''; if (isset($_GET['m'])) { $m = $_GET['m']; } if (isset($_GET['year'])) { $m = $_GET['year']; } if (isset($_GET['monthnum'])) { $m .= $_GET['monthnum']; } if (isset($_GET['day'])) { $m .= $_GET['day']; } if ($m != '') { switch(strlen($m)) { case 4: //archive is year $m = (int)$m; $m++; $past = $wpdb->get_row("SELECT post_date, YEAR(post_date) as year FROM $tableposts WHERE YEAR(post_date) >= '".$m."' AND post_status = 'publish' ORDER BY post_date ASC"); if ($past) { echo $before."year)."\">".$past->year."".$after; } break; case 6: //archive is month $thisYear = substr($m, 0, 4); $thisMonth = substr($m, 4, 2); if (substr($thisMonth,0,1) == '0') { $thisMonth = substr($m, 5, 1); } $thisMonth = (int)$thisMonth; $thisYear = (int)$thisYear; $timestamp = mktime(0, 0, 0, $thisMonth+1, 1, $thisYear); $currentdate = date("Y-m-d G:i:s", $timestamp); //echo $currentdate; $past = $wpdb->get_row("SELECT post_date, YEAR(post_date) as year, MONTH(post_date) as month FROM $tableposts WHERE post_date >= '".$currentdate."' AND post_status = 'publish' ORDER BY post_date ASC"); $timestampfordisplay = mktime(0,0,0,$past->month,1,$past->year); $forDisplay = __(date("F", $timestampfordisplay)); $forDisplay .= " ".date("Y", $timestampfordisplay); if ($past) { echo $before."year,$past->month)."\">".$forDisplay."".$after; } break; case 8: //archive is day YYYYMMDD $thisYear = substr($m, 0, 4); $thisMonth = substr($m, 4, 2); $thisDay = substr($m, 6, 2); if (substr($thisDay,0,1) == '0') { $thisDay = substr($m, 7, 1); } if (substr($thisMonth,0,1) == '0') { $thisMonth = substr($m, 5, 1); } $thisDay = (int)$thisDay; $thisMonth = (int)$thisMonth; $thisYear = (int)$thisYear; $timestamp = mktime(0, 0, 0, $thisMonth, $thisDay+1, $thisYear); $currentdate = date("Y-m-d G:i:s", $timestamp); //echo $currentdate; $past = $wpdb->get_row("SELECT post_date, YEAR(post_date) as year, MONTH(post_date) as month, DAYOFMONTH(post_date) as day FROM $tableposts WHERE post_date >= '".$currentdate."' ORDER BY post_date ASC"); $timestampfordisplay = mktime(0,0,0,$past->month,$past->day,$past->year); $forDisplay = __(date("F", $timestampfordisplay)); $forDisplay .= " ".date("j, Y", $timestampfordisplay); if ($past) { echo $before."year,$past->month,$past->day)."\">".$forDisplay."".$after; } break; } } } //Thanks to Charles G. of blindmuse.com for this function if (!function_exists('get_year_link')) { function get_year_link($year) { global $siteurl, $blogfilename, $querystring_start, $querystring_equal; if (!$year) $year = date('Y', time()+($time_difference * 3600)); if ('' != get_settings('permalink_structure')) { $off = strpos(get_settings('permalink_structure'), '%year%'); $offset = $off + 7; $yearlink = substr(get_settings('permalink_structure'), 0, $offset); $yearlink = str_replace('%year%', $year, $yearlink); return get_settings('home').$yearlink; } else { return get_settings('home').'/'.get_settings('blogfilename').$querystring_start.'ye ar'.$querystring_equal.$year; } } } ?>