我正在创建一个Wordpress自定义帖子类型,包括一个分类法,在安装之后,所有的永久链接都被刷新了,但是分类法归档页面不断给我404。
CPT归档页面工作得非常好。
要创建的代码:
add_action( \'init\', \'register_cpt_post_type\' );
function register_cpt_post_type() {
register_post_type( \'offers\',
array(
\'labels\' => array(
\'name\' => \'Offer Posts\',
\'menu_name\' => \'Offers Manager\',
\'singular_name\' => \'Offer post\',
\'all_items\' => \'All Offers Posts\'
),
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_nav_menus\' => true,
\'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\', \'comments\', \'post-formats\', \'revisions\' ),
\'hierarchical\' => false,
\'has_archive\' => \'offers\',
\'show_in_rest\' => true,
\'taxonomies\' => array(\'offers-category\')
)
);
register_taxonomy( \'offers-category\', array( \'offers\' ),
array(
\'labels\' => array(
\'name\' => \'Offer Categories\',
\'menu_name\' => \'Offer Categories\',
\'singular_name\' => \'Offers Category\',
\'all_items\' => \'All Categories\'
),
\'public\' => true,
\'hierarchical\' => true,
\'show_ui\' => true,
\'show_in_rest\' => true,
\'rewrite\'=>array( \'slug\'=>\'offers\' )
)
);
}
如果我尝试访问www.xxx。com/offers->它工作得非常好,并为我提供了存档页面模板
如果我尝试访问www.xxx。com/offers/food->如果食品是一个类别,页面将指向404。
如果我设置了一些错误,你能指导我吗?