最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Set up Custom Taxonomy Archive Template File To Cover 3 Categories

programmeradmin3浏览0评论

I have a custom post type that has 3 customer taxonomies (categories).

I'd like to set up a custom taxonomy archive template file which will be the same design for all 3 custom categories.

In the template file system, how do I set up a custom taxonomy archive to cover all 3 categories? I tried category.php but this doesn't seem to work?

Also there is a taxonomy.php template file and a category.php template file and I don't understand the difference between them?

Surely I don't have to set up three individual archive template files for the 3 categories? And if I do how do I name them? The 3 categories are 'Design', 'Art' and 'Media' and the custom post type is 'News'.

Any assistance would be wonderful.

The code in my functions file is:

function news_taxonomy(){

$labels = array(
'name' => 'News Categories',
'singular_name' => 'News Category',
'search_items' => 'Search News Categories',
'all_items' => 'All News Categories',
'parent_item' => 'Parent News Category',
'parent_item_colon' => 'Parent News Category:',
'edit_item' => 'Edit News Category',
'update_item' => 'Update News Category',
'add_new_item' => 'Add New News Category',
'new_item_name' => 'New News Category Name',
'menu_name' => 'News Category',
);

$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'news_categories' ),
);

   register_taxonomy( 'news_categories', array( 'news' ), $args );
}

add_action('init', 'news_taxonomy');
发布评论

评论列表(0)

  1. 暂无评论