在我看来,你可以:
// Via the init hook, do all these:
register_post_type( \'library-books\', [
\'public\' => true,
\'label\' => \'Library Books\',
\'rewrite\' => [ \'with_front\' => false, \'slug\' => \'library/books\' ],
\'has_archive\' => \'library/books\',
// other args here
] );
register_post_type( \'library\', [
\'public\' => true,
\'label\' => \'Libraries\',
\'rewrite\' => [ \'with_front\' => false, \'slug\' => \'library\' ],
\'has_archive\' => false,
// other args here
] );
add_rewrite_rule( \'^library/?$\', \'index.php?library=home\', \'top\' );
一、 e。
注册library-books
先进行CPT,然后进行library/books
作为重写slug以及has_archive
.
然后注册library
CPT带library
作为重写段塞,以及has_archive
设置为false
.
并为example.com/library
哪些(内部)负载example.com/library/home
(这是library
CPT,尽管您确实可以修改重写规则的查询以加载不同帖子类型的帖子,例如page
).
当然,在library
CPT,你不应该在books
就像鼻涕虫一样。