I have 3 custom post types - Events, Music and Video. I have custom article pages for these 3 post types as having them on a singular archive page would be bloated. So i have:
- archive-events.php
- archive-music.php
- archive-video.php
When a taxonomy is clicked (Tag or Category) it defaults to the standard archive page. To rectify this I have set up custom taxonomy templates ie. taxonomy-tagevents.php
. This work perfectly. My question is though, I presume there is a better way to do this so I don't have 3 copies of taxonomy-(custom-taxonomy). Is there a way to direct the taxonomy to the custom post type archive page?
UPDATE
<?php
// Register Custom Post Type
function custom_post_type_music() {
$labels = array(
'name' => _x( 'Music', 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( 'Music', 'Post Type Singular Name', 'text_domain' ),
'menu_name' => __( 'Music', 'text_domain' ),
'parent_item_colon' => __( 'Parent Music:', 'text_domain' ),
'all_items' => __( 'All Music', 'text_domain' ),
'view_item' => __( 'View Music', 'text_domain' ),
'add_new_item' => __( 'Add New Music Tracks', 'text_domain' ),
'add_new' => __( 'New Music Tracks', 'text_domain' ),
'edit_item' => __( 'Edit Music', 'text_domain' ),
'update_item' => __( 'Update Music', 'text_domain' ),
'search_items' => __( 'Search Music', 'text_domain' ),
'not_found' => __( 'No Music found', 'text_domain' ),
'not_found_in_trash' => __( 'No Music found in Trash', 'text_domain' ),
);
$args = array(
'label' => __( 'Music', 'text_domain' ),
'description' => __( 'Music information pages', 'text_domain' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'thumbnail', 'comments', 'revisions', ),
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'menu_icon' => '',
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
);
register_post_type( 'Music', $args );
// Initialize Taxonomy Labels
$labels = array(
'name' => _x( 'Categories', 'taxonomy general name', 'text_domain' ),
'singular_name' => _x( 'Category', 'taxonomy singular name', 'text_domain' ),
'search_items' => __( 'Search Types', 'text_domain' ),
'all_items' => __( 'All Categories', 'text_domain' ),
'parent_item' => __( 'Parent Category', 'text_domain' ),
'parent_item_colon' => __( 'Parent Category:', 'text_domain' ),
'edit_item' => __( 'Edit Categories', 'text_domain' ),
'update_item' => __( 'Update Category', 'text_domain' ),
'add_new_item' => __( 'Add New Category', 'text_domain' ),
'new_item_name' => __( 'New Category', 'text_domain' ),
);
// Register Custom Taxonomy
register_taxonomy('tagmusic',array('music'), array(
'hierarchical' => true, // define whether to use a system like tags or categories
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'cat-music' ),
));
}
// Hook into the 'init' action
add_action( 'init', 'custom_post_type_music', 0 );
single-{post-type}.php
, notarticle-{post-type}.php
. And WordPress doesn't supporttaxonomy-{post-type}.php
; rather, it supportstaxonomy-{taxonomy}.php
andtaxonomy-{taxonomy}-{term}.php
.taxonomy-{taxonomy}.php
template files. Please add your relevant code, in context - including yourregister_post_type()
andregister_taxonomy()
calls. Also: by "article page", do you mean custom page template?