我正在尝试通过url链接到自定义帖子类型。所以我有CPT“论坛”(example.com/forums)和CPT“主题”(example.com/topics)
我正在尝试实现两个组合的url(对于CPT“主题”),并在两者之间添加元数据(例如:com/forums/forumname/topic/topicname),这可能吗?
//register post type
register_post_type( \'forums\', array(
\'labels\' => $labels,
\'has_archive\' => true,
\'public\' => true,
\'supports\' => array( \'title\', \'editor\', \'excerpt\', \'thumbnail\',\'page-attributes\' ),
\'taxonomies\' => array( ),
\'exclude_from_search\' => false,
\'capability_type\' => \'page\',
\'rewrite\' => array( \'slug\' => \'forums\' ),
)
);
它与正确的url(example.com/forums/)配合使用。
//register post type
register_post_type( \'topics\', array(
\'labels\' => $labels,
\'has_archive\' => true,
\'public\' => true,
\'supports\' => array( \'title\', \'editor\', \'excerpt\', \'thumbnail\',\'page-attributes\' ),
\'taxonomies\' => array( \'post_tag\'),
\'exclude_from_search\' => false,
\'capability_type\' => \'post\',
\'rewrite\' => array(
\'slug\' => \'forums/topic\',
\'with_front\' => true
),
)
);
这打破了CPT“主题”的永久链接。我不太了解URL重写,需要有人带我了解一下,或者至少给我指出正确的方向。我一直在阅读指南,但我只是变得更加困惑。