If my category URL is:
/blogs/category/foo
and my archive URL is:
/blogs/2011/02/
what’s the URL for ‘foo’ blogs from February 2011?
If my category URL is:
/blogs/category/foo
and my archive URL is:
/blogs/2011/02/
what’s the URL for ‘foo’ blogs from February 2011?
There is no date-based archive for a category. The /category/[slug]/
pages are already “archives”, in that they display old posts over different pages.
The different pages can be accessed by adding page/2/
, page/3/
, … to the URL. The template tags to add these links are next_posts_link()
and previous_posts_link()
.
If you want to add a date-based layer to your category archives, you can add a rewrite rule to match a year, optional month and optional paging.
add_filter( 'category_rewrite_rules', 'wpse8769_category_rewrite_rules' );
function wpse8769_category_rewrite_rules( $category_rules )
{
global $wp_rewrite;
// This could be incorrect for fancy permastructs, only tested in simple situations
$category_permastruct = str_replace( $wp_rewrite->rewritecode, $wp_rewrite->rewritereplace, $wp_rewrite->get_category_permastruct() );
$category_permastruct = preg_replace( '|^/+|', '', $category_permastruct );
$category_extra_rules = array(
// Or split this up over different rewrite rules, if the regex is too complicated
// Feeds are left as an exercise for the reader
$category_permastruct . '/([0-9]{4})(/([0-9]{1,2}))?(/page/([0-9]+))?/?$' =>
'index.php?category_name=$matches[1]&year=$matches[2]&monthnum=$matches[4]&paged=$matches[6]',
);
return $category_extra_rules + $category_rules;
}