我有一个自定义帖子类型“车辆”,具有“分类”制造商。
我在添加任何帖子之前创建了术语“奥迪”,并且使用模板archive-vehicles
上的默认wp循环就可以很好地显示与该单词相关的帖子。但是,如果我添加一个新术语(例如“ ford”),然后为该术语分配一个现有帖子,那么该帖子不会显示在存档中吗?如果我将术语“ audi”和“ ford”分配给帖子,那么它会出现在存档中吗?
任何人都可以考虑为什么发生这种情况以及如何解决吗?
函数文件中的分类法:
function create_manufacturer_hierarchical_taxonomy() {
$labels = array(
'name' => _x( 'Manufacturer', 'taxonomy general name' ),
'singular_name' => _x( 'Manufacturer', 'taxonomy singular name' ),
'search_items' => __( 'Search Manufacturers' ),
'all_items' => __( 'All Manufacturers' ),
'parent_item' => __( 'Parent Manufacturer' ),
'parent_item_colon' => __( 'Parent Manufacturer:' ),
'edit_item' => __( 'Edit Manufacturer' ),
'update_item' => __( 'Update Manufacturer' ),
'add_new_item' => __( 'Add New Manufacturer' ),
'new_item_name' => __( 'New Manufacturer Name' ),
'menu_name' => __( 'Manufacturers' ),
);
register_taxonomy('manufacturer',array('vehicles'), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'manufacturer' ),
));
}
功能文件中的自定义帖子类型:
function create_post_type_cars()
{
register_taxonomy_for_object_type('manufacturer', 'vehicles');
register_taxonomy_for_object_type('body', 'vehicles');
register_post_type('vehicles',
array(
'labels' => array(
'name' => __('Vehicles', 'cars'),
'singular_name' => __('Vehicle', 'cars'),
'add_new' => __('Add New', 'cars'),
'add_new_item' => __('Add New Vehicle', 'cars'),
'edit' => __('Edit', 'cars'),
'edit_item' => __('Edit Vehicle', 'cars'),
'new_item' => __('New Vehicle', 'cars'),
'view' => __('View Vehicle', 'cars'),
'view_item' => __('View Vehicle', 'cars'),
'search_items' => __('Search Vehicles', 'cars'),
'not_found' => __('No Vehicles found', 'cars'),
'not_found_in_trash' => __('No Vehicles found in Trash', 'cars')
),
'public' => true,
'menu_position' => 5,
'menu_icon' => get_template_directory_uri().'/img/icons/portfolios-icon.png',
'hierarchical' => true,
'has_archive' => true,
'supports' => array(
'title',
'editor',
'excerpt',
'thumbnail'
),
'can_export' => true,
'taxonomies' => array(
'manufacturer',
'body'
)
));
}