我创建了一个带有两个自定义分类法的自定义帖子类型,最终将用于过滤自定义帖子类型中的结果。我遇到的问题是,我希望URL为:
网站url/自定义帖子类型/自定义分类法
我曾尝试在这里为有类似问题的人提供一些建议,但在这种情况下我无法使其工作。这是我目前拥有的代码,我已经将其剥离回去,因为尝试使其工作是徒劳的:
//Custom Post Types
add_action( \'init\', \'create_post_type\' );
function create_post_type() {
register_post_type( \'listing\',
array(
\'labels\' => array(
\'name\' => __( \'Listings\' ),
\'singular_name\' => __( \'Listing\' )
),
\'public\' => true,
\'has_archive\' => true,
\'show_ui\' => true,
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'rewrite\' => array( \'slug\' => \'directory\', \'with_front\' => false ),
\'query_var\' => false,
\'supports\' => array( \'title\', \'editor\' )
)
);
}
//Region Taxonomies
function region_taxonomy() {
register_taxonomy(
\'region\',
\'listing\',
array(
\'hierarchical\' => true,
\'label\' => \'Regions\',
\'query_var\' => true,
\'rewrite\' => array(\'slug\' => \'region\', \'with_front\' => true )
)
);
}
add_action( \'init\', \'region_taxonomy\' );
//Qualifications Taxonomies
function qualification_taxonomy() {
register_taxonomy(
\'qualification\',
\'listing\',
array(
\'hierarchical\' => true,
\'label\' => \'Qualifications\',
\'query_var\' => true,
\'rewrite\' => array(\'slug\' => \'qualification\' )
)
);
}
目前,这将产生:网站url/地区/或/资格/
如果有人能帮我解决这件事,那就太好了,浪费了很多时间到处转圈!