这个问题以前可能被问过,但我的语言不是英语,我真的找不到答案:
我得到了一个自定义的帖子类型:productsandscustom(hierarchy)taxonomy:collection
在axample的分类法中:-绘画(父税)--经典(子税)--现代(子税)
现在我想通过以下途径接触我的产品:收藏/绘画/经典/经典-绘画-1,但我有两个问题:
问题1:子税在url中没有父税:collection/paints/然后collection/classic/。。应该是收藏/绘画/经典/
问题2:如果我在“收藏/绘画”中选择一个产品(如classic-Paint-1),则转到“产品/classic-Paint-1”,而不是“收藏/绘画/classic/classic-Paint-1”
我希望这个大问题有一个简单的答案,提前谢谢
自定义帖子类型和分类的我的代码:
// Custom post type
add_action(\'init\', \'cptui_register_my_cpt_producten\');
function cptui_register_my_cpt_producten() {
register_post_type(\'producten\', array(
\'label\' => \'Producten\',
\'description\' => \'\',
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'capability_type\' => \'post\',
\'map_meta_cap\' => true,
\'hierarchical\' => true,
\'rewrite\' => array(\'slug\' => \'producten\', \'with_front\' => true),
\'query_var\' => true,
\'menu_position\' => \'1\',
\'supports\' => array(\'title\',\'editor\'),
\'taxonomies\' => array(\'category\',\'post_tag\',\'collectie\'),
\'labels\' => array (
\'name\' => \'Producten\',\'singular_name\' => \'Product\',\'menu_name\' => \'Producten\',\'add_new\' => \'Add Product\',\'add_new_item\' => \'Add New Product\',\'edit\' => \'Edit\',\'edit_item\' => \'Edit Product\',\'new_item\' => \'New Product\',\'view\' => \'View Product\',\'view_item\' => \'View Product\',\'search_items\' => \'Search Producten\',\'not_found\' => \'No Producten Found\',\'not_found_in_trash\' => \'No Producten Found in Trash\',\'parent\' => \'Parent Product\',
)
) ); }
// Custom taxonomy
add_action(\'init\', \'cptui_register_my_taxes_collectie\');
function cptui_register_my_taxes_collectie() {
register_taxonomy( \'collectie\',array (
0 => \'producten\',
),
array( \'hierarchical\' => true,
\'label\' => \'Collecties\',
\'show_ui\' => true,
\'query_var\' => true,
\'show_admin_column\' => false,
\'labels\' => array (
\'search_items\' => \'Collectie\',
\'popular_items\' => \'\',
\'all_items\' => \'\',
\'parent_item\' => \'\',
\'parent_item_colon\' => \'\',
\'edit_item\' => \'\',
\'update_item\' => \'\',
\'add_new_item\' => \'\',
\'new_item_name\' => \'\',
\'separate_items_with_commas\' => \'\',
\'add_or_remove_items\' => \'\',
\'choose_from_most_used\' => \'\',
)
) );
}