我正在尝试将分页添加到自定义帖子类型的归档中。目前,它是按年度和;月,我想添加分页,但我失败得很惨。
所以是这样的:
<!-- Request: cpt/2014/pagina/2 -->
<!-- Matched Rewrite Rule: cpt/([0-9]{4})/pagina/?([0-9]{1,})/?$ -->
<!-- Matched Rewrite Query: post_type=cpt&year=2014&paged=2 -->
<!-- Loaded Template: index.php -->
它应该加载
archive-cpt.php
像这样:
<!-- Request: cpt/2014 -->
<!-- Matched Rewrite Rule: cpt/([0-9]{4})/?$ -->
<!-- Matched Rewrite Query: post_type=cpt&year=2014 -->
<!-- Loaded Template: archive-cpt.php -->
对一些人来说
special 我在帖子中添加了一个标记,效果很好。(此处分页也失败)
<!-- Request: cpt/marker -->
<!-- Matched Rewrite Rule: evenimente/marker/?$ -->
<!-- Matched Rewrite Query: post_type=cpt&marker=yes -->
<!-- Loaded Template: archive-cpt.php -->
我把自己绑在
init
并添加如下规则:
add_rewrite_rule( #works
$cpt_name. \'/marker/?$\',
\'index.php?post_type=\' . $cpt_slug . \'&marker=yes\',
\'top\'
);
add_rewrite_rule( #fails
$cpt_name . \'/marker/page/([0-9]{1,})/?$\',
\'index.php?post_type=\' . $cpt_slug . \'&paged=$matches[1]&marker=yes\',
\'top\'
);
我做错了什么?