【发布时间】:2014-02-19 14:06:50
【问题描述】:
我的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
【问题讨论】:
标签: php wordpress archive custom-post-type