我已经在我的函数中注册了自定义的post类型。“Wines”的php文件,代码如下:
function customposttype_wines() {
$labels = array(
\'name\' => \'Wines\',
\'singular_name\' => \'Wine\',
\'menu_name\' => \'Wines\',
\'parent_item_colon\' => \'Parent Wine\',
\'all_items\' => \'All Wines\',
\'view_item\' => \'View Wine\',
\'add_new_item\' => \'Add New Wine\',
\'add_new\' => \'+\',
\'edit_item\' => \'Edit Wine\',
\'update_item\' => \'Update Wine\',
\'search_items\' => \'Search Wines\',
\'not_found\' => \'No Wines found\',
\'not_found_in_trash\' => \'No Wines found in Trash\',
);
$args = array(
\'label\' => \'wines\',
\'description\' => \'Wine Reviews\',
\'labels\' => $labels,
\'supports\' => array( \'title\', ),
\'unset\' => array (\'date\'),
\'hierarchical\' => false,
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_nav_menus\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 5,
\'can_export\' => true,
\'has_archive\' => true,
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'capability_type\' => \'post\',
);
register_post_type(
\'wines\',
$args
);
}
add_action( \'init\', \'customposttype_wines\', 0 );
并使用此代码注册了9个自定义分类法(品牌、地区、葡萄等)(仅使用
<XXX>
为每个更改):
function customtaxonomy_<XXX> () {
$labels = array(
\'name\' => \'<XXX>\',
\'singular_name\' => \'<XXX>\',
\'menu_name\' => \'<XXX>s\',
\'all_items\' => \'All <XXX>s\',
\'parent_item\' => \'Parent <XXX>\',
\'parent_item_colon\' => \'Parent <XXX>:\',
\'new_item_name\' => \'New <XXX> Name\',
\'add_new_item\' => \'Add New <XXX>\',
\'edit_item\' => \'Edit <XXX>\',
\'update_item\' => \'Update <XXX>\',
\'separate_items_with_commas\' => \'Separate <XXX>s w/commas\',
\'search_items\' => \'Search <XXX>s\',
\'add_or_remove_items\' => \'Add or Remove <XXX>s\',
\'choose_from_most_used\' => \'Choose from the most used <XXX>s\',
);
$args = array(
\'labels\' => $labels,
\'hierarchical\' => true,
\'public\' => true,
\'show_ui\' => true,
\'show_admin_column\' => true,
\'show_in_nav_menus\' => true,
\'show_tagcloud\' => true,
\'query_var\' => true,
);
register_taxonomy(
\'<XXX>s\',
\'wines\',
$args
);
}
add_action( \'init\', \'customtaxonomy_<XXX>\', 0 );
现在我试图在每个的父页面上显示自定义分类术语的列表,所以在访问www.mywebsite时。com/葡萄酒/
<XXX>
有一个列表,其中包含已输入的所有术语的链接。
现在当我访问www.mywebsite时。com/葡萄酒/<XXX>
我刚看到404。php错误页。但是,如果我访问分类术语页面,我会很好地看到其中的帖子,即:www.mywebsite。com/葡萄酒/<XXX>
/学期
我尝试使用分类模板层次结构页面,taxonomy-<XXX>.php
但它不会加载,仍然只显示404。php。
在这里拉头发,非常感谢您的帮助。