[wp-hackers] Making use of "nicer" url for archive pages?

Charles G. chuckg at blindmuse.com
Wed Nov 3 19:40:32 UTC 2004


> Try get_month_link() and get_day_link().

I wrote a plugin a while back that required me to create links which were
specific to a year, which as of yet, has not been included in the base
Wordpress code.  They are similar in form to that of the get_month_link()
and get_day_link(), however they fetch the year link in whatever format the
user has set in their preferences. It follows along the lines of what it is
I believe you are trying to do.

In any case, here's the code:
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;
        }
    }
}


Charles G.




More information about the hackers mailing list