我创建了两种自定义帖子类型:
add_action( \'init\', \'register_post_types\' );
function register_post_types() {
register_post_type(
\'jobsearch-post\',
array(
\'labels\' => array(
\'name\' => __( \'Job Searches Post\' ),
\'singular_name\' => __( \'Job Search Post\' )
),
\'public\' => true,
\'has_archive\' => true,
\'rewrite\' => array(
\'slug\' => \'jobsearch\'
)
)
);
register_post_type(
\'recruiters-post\',
array(
\'labels\' => array(
\'name\' => __( \'Recruiters Post\' ),
\'singular_name\' => __( \'Recruiter Post\' )
),
\'public\' => true,
\'has_archive\' => true,
\'rewrite\' => array(
\'slug\' => \'recruiters\'
)
)
);
}
看起来工作正常。然而,我有几个相关的分类法:
add_action( \'init\', \'register_taxonomies\' );
function register_taxonomies() {
register_taxonomy(
\'recruiters-tax\',
array (
0 => \'recruiters-post\',
),
array(
\'hierarchical\' => true,
\'label\' => \'Recruiters Taxonomy\',
\'show_ui\' => true,
\'query_var\' => true,
\'rewrite\' => array(
\'slug\' => \'\'
),
\'singular_label\' => \'Recruiter Taxonomy\'
)
);
register_taxonomy(
\'jobsearch-tax\',
array (
0 => \'jobsearch-post\',
),
array(
\'hierarchical\' => true,
\'label\' => \'Job Searches Taxonomy\',
\'show_ui\' => true,
\'query_var\' => true,
\'rewrite\' => array(
\'slug\' => \'\'
),
\'singular_label\' => \'Job Search Taxonomy\'
)
);
}
正如您所看到的,这些是分层的。但不幸的是,只有当我尝试访问招聘人员分类中的项目时,我才能得到404,例如:
http://localhost:8888/recruiters/some-category
我可以访问职位公告:http://localhost:8888/jobsearch/some-category
我还可以访问根自定义帖子类型:http://localhost:8888/recruiters
http://localhost:8888/jobsearch
是否有什么东西使我无法仅从招聘人员分类法中获得嵌套分类法?
请注意,我一直在我的永久链接设置中点击“保存更改”按钮,以使其正常工作。
这快把我逼疯了!