我创建了自定义帖子类型
add_action(\'after_setup_theme\', \'cptui_register_my_cpt_packaged\');
function cptui_register_my_cpt_packaged() {
register_post_type(\'packaged\', array(
\'label\' => \'Packaged Foods\',
\'description\' => \'\',
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'capability_type\' => \'post\',
\'map_meta_cap\' => true,
\'hierarchical\' => false,
\'rewrite\' => array(\'slug\' => \'packaged-foods-list\', \'with_front\' => false ),
\'query_var\' => true,
\'has_archive\' => true,
\'supports\' => array(\'title\',\'editor\',\'excerpt\',\'trackbacks\',\'custom-fields\',\'comments\',\'revisions\',\'thumbnail\',\'author\',\'page-attributes\',\'post-formats\'),
\'taxonomies\' => array(\'post_tag\',\'pf_cat\',\'pf_groc_cat\'),
\'labels\' => array (
\'name\' => \'Packaged Foods\',
\'singular_name\' => \'Packaged Food\',
\'menu_name\' => \'Packaged Foods\',
\'add_new\' => \'Add Packaged Food\',
\'add_new_item\' => \'Add New Packaged Food\',
\'edit\' => \'Edit\',
\'edit_item\' => \'Edit Packaged Food\',
\'new_item\' => \'New Packaged Food\',
\'view\' => \'View Packaged Food\',
\'view_item\' => \'View Packaged Food\',
\'search_items\' => \'Search Packaged Foods\',
\'not_found\' => \'No Packaged Foods Found\',
\'not_found_in_trash\' => \'No Packaged Foods Found in Trash\',
\'parent\' => \'Parent Packaged Food\',
)
) ); }
还有两种分类法,即pf\\U cat和pf\\U groc\\U cat
我正在尝试创建一个自定义的帖子类型存档模板,它总是默认为存档。php
以下是分类法:
add_action(\'after_setup_theme\', \'cptui_register_my_taxes_pf_cat\');
function cptui_register_my_taxes_pf_cat() {
register_taxonomy( \'pf_cat\',array (
0 => \'packaged\',
),
array( \'hierarchical\' => true,
\'label\' => \'PF Categories\',
\'show_ui\' => true,
\'query_var\' => true,
\'show_admin_column\' => false,
\'labels\' => array (
\'search_items\' => \'PF Category\',
\'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\' => \'\',
)
) );
}
add_action(\'after_setup_theme\', \'cptui_register_my_taxes_pf_groc_cat\');
function cptui_register_my_taxes_pf_groc_cat() {
register_taxonomy( \'pf_groc_cat\',array (
0 => \'packaged\',
),
array( \'hierarchical\' => true,
\'label\' => \'PF Grocery Categories\',
\'show_ui\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'packaged-foods\' ),
\'show_admin_column\' => false,
\'labels\' => array (
\'search_items\' => \'PF Grocery Category\',
\'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\' => \'\',
)
) );
}
我不熟悉CPT和分类法,我在这里真的很挣扎。我在这里读到了另一个非常类似的问题,他被要求尝试带有自定义帖子类型的URL
http://[网址]。com/?post\\u type=打包使用打包的存档。php模板。http://[网址]。com/?post\\u类型=打包(&U);包装食品=有机葡萄酒也有效。
但是,当我尝试http://[websitehere]时。com/包装食品/有机葡萄酒/默认为存档。php
我到底做错了什么?
提前谢谢。