【发布时间】:2017-01-28 02:51:03
【问题描述】:
好的,在尝试像我通常做的重写一样自己做之后(但这次出于某种原因,没有运气)我找到了这个答案:
Custom post type yearly/ monthly archive
但仍然不适合我。 如果我记录规则,我可以找到正确的,它会被正确写入:
["it/press-release/([0-9]{4})/?$"]=>
string(50) "index.php?post_type=press_article&year=$matches[1]"
为了完整起见,登录规则的第一行是(见下面最后一行,没错):
array(309) {
["it/press-release/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$"]=>
string(87) "index.php?post_type=press_article&year=$matches[1]&monthnum=$matches[2]&day=$matches[3]"
["it/press-release/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$"]=>
string(104) "index.php?post_type=press_article&year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]"
["it/press-release/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$"]=>
string(104) "index.php?post_type=press_article&year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]"
["it/press-release/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/([0-9]{1,})/?$"]=>
string(105) "index.php?post_type=press_article&year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&paged=$matches[4]"
["it/press-release/([0-9]{4})/([0-9]{1,2})/?$"]=>
string(71) "index.php?post_type=press_article&year=$matches[1]&monthnum=$matches[2]"
["it/press-release/([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$"]=>
string(88) "index.php?post_type=press_article&year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]"
["it/press-release/([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$"]=>
string(88) "index.php?post_type=press_article&year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]"
["it/press-release/([0-9]{4})/([0-9]{1,2})/page/([0-9]{1,})/?$"]=>
string(89) "index.php?post_type=press_article&year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]"
["it/press-release/([0-9]{4})/?$"]=>
string(50) "index.php?post_type=press_article&year=$matches[1]"
但还是不行。如果我尝试导航到it/press-release/2016(是的,有那个日期的帖子)我会被重定向到首页。
我必须说几件事:
- 我使用 polylang
-
我的自定义帖子类型是这样注册的:
$args = array( 'public' => true, 'supports' => array('title','editor','page-attributes'), 'description' => 'Rassegna stampa', 'labels' => $labels, // omitting here since not relevant 'rewrite' => array('slug' => pll__('rassegna-stampa')), 'has_archive' => true, 'menu_icon' => 'dashicons-media-document' );//end args register_post_type('press_article',$args);
有人能发现问题吗?
【问题讨论】:
标签: php wordpress url-rewriting custom-post-type