我正在为WP 3.1中名为articles的自定义帖子类型创建一个分类页面,在提取页码时遇到了一些问题。
url:/articles/category/background/
目前,我的functions.php
:
add_action( \'init\', \'wpse7379_init\' );
function wpse7379_init() {
add_rewrite_rule(
\'articles/category/([^/]+)(/page/([0-9]+))/?$\',
\'index.php?post_type=articles&category_name=$matches[1]&paged=$matches[2]\',
\'top\'
);
}
这会在内部将url重写为:/index.php?post_type=articles&category_name=background
我试图通过扩展重写规则来实现分页,但它对我不起作用。
分页工作如下:/articles/category/background/page/2/
新规则:
add_rewrite_rule(
\'articles/category/([^/]+)(/page/([0-9]+))/?$\',
\'index.php?post_type=articles&category_name=$matches[1]&paged=$matches[2]\',
\'top\'
);
这应将url重写为:/index.php?post_type=articles&category_name=background&paged=2
我在我的archive-articles.php
页面,但只是categories.php
页面,其中显示帖子。
当我尝试时/index.php?post_type=articles&category_name=background&paged=2
它可以工作,但被重写的url不能工作。它只显示第一页,不管我输入的页码是多少。
有人知道如何解决这个问题吗?I think I\'m looking for a proper regex, I kinda suck at regexes, so I guess thats the problem.