我有3种自定义帖子类型-活动、音乐和视频。我有这3种帖子类型的自定义文章页面,因为将它们放在一个单一的归档页面上会显得臃肿。所以我有:
存档事件。php存档音乐。php存档视频。php单击分类法(标记或类别)时,它默认为标准存档页面。为了纠正这个问题,我设置了自定义分类模板ie。taxonomy-tagevents.php
. 这工作做得很好。但我的问题是,我认为有更好的方法来实现这一点,所以我没有3个分类法副本-(自定义分类法)。有没有办法将分类法定向到自定义帖子类型归档页面?
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 );