我在functions.php中有以下代码:
function add_rewrite_rules($aRules) {
$aNewRules = array(
'news/([0-9]{4})/page/?([0-9]{1,})/?$' => 'index.php?post_type=news&year=$matches[1]&paged=$matches[2]',
'news/([0-9]{4})/?$' => 'index.php?post_type=news&year=$matches[1]',
'blog/([0-9]{4})/page/?([0-9]{1,})/?$' => 'index.php?post_type=blog&year=$matches[1]&paged=$matches[2]',
'blog/([0-9]{4})/?$' => 'index.php?post_type=blog&year=$matches[1]'
);
$aRules = $aNewRules + $aRules;
return $aRules;
}
add_filter('rewrite_rules_array', 'add_rewrite_rules');
这使我的永久链接工作如下:
/blog
/blog/post-name
/blog/2014
我不太了解代码,以使其适应月度档案,如:
/blog/2014/01
答案 0 :(得分:0)
尝试添加
'blog/([0-9]{4})/([0-9]{1,2})/?$' => 'index.php?post_type=blog&year=$matches[1]&monthnum=$matches[2]'
到您的阵列。