如果我的类别URL为:
/博客/类别/foo
我的存档URL是:
/博客/2011/02/
2011年2月起“foo”博客的URL是什么?
如果我的类别URL为:
/博客/类别/foo
我的存档URL是:
/博客/2011/02/
2011年2月起“foo”博客的URL是什么?
类别没有基于日期的存档。这个/category/[slug]/
页面已经是“档案”,因为它们在不同的页面上显示旧帖子。
可以通过添加page/2/
, page/3/
, ... 到URL。要添加这些链接的模板标记包括next_posts_link()
和previous_posts_link()
.
如果要将基于日期的图层添加到类别存档中,可以添加重写规则以匹配年份、可选月份和可选分页。
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;
}
Q: what\'s the URL for \'foo\' blogs from February 2011?
网站上下文中的URL为:/blogs/category/foo/?y=2011&monthnum=02
(我明目张胆地抄袭了t31os的命令,所以这要归功于他)
如何更改附件页URL的格式/[post-url]/[attachment-name]/ 到/media/[attachment-name]/? 我知道我可以覆盖get_attachment_link 通过attachment_link 过滤器,但我想我需要更改重定向结构,以便WordPress知道如何处理这些URL?