0
Good afternoon. I am creating a site with more than one Custom Post Type. For example: Custom Post Type "A" has the taxonomy "Types" (type 1 and Tipo2). Custom Post Type "B" has the taxonomy "Years" (2016, 2015...).
I created a file taxonomy-tipos.php
for Custom Post Type "A". So I can list all items of type 1 and Tipo2 separately. This one worked.
So I created a file taxonomy-anos.php
to list the items for a given year. But this time it didn’t work. When I click on a year, wp picks up the template index.php
and not the taxonomy-anos.php
.
(I simplified the names to facilitate understanding).
The taxonomy creation code I used is transcribed below. It’s in the file functions.php
. The archive with the template for this taxonomy would be the taxonomy-productionyear.php
. That’s exactly what I did for another Custom Post Type, which has another taxonomy.
add_action('init', 'taxonomy_production_year');
function taxonomy_production_year(){
$labels = array(
'name' => _x( 'Publications Years', 'taxonomy general name' ),
'singular_name' => _x( 'Publication Year', 'taxonomy singular name' ),
'search_items' => __( 'Search for Year' ),
'all_items' => __( 'All Years' ),
'parent_item' => __( 'Parent Year' ),
'parent_item_colon' => __( 'Parent Year:' ),
'edit_item' => __( 'Edit Year' ),
'update_item' => __( 'Update Year' ),
'add_new_item' => __( 'Add New Year' ),
'new_item_name' => __( 'New Year' ),
'menu_name' => __( 'Year' ),
);
$args = array(
'hierarchical' => false,
'label' => __( 'Year' ),
'labels' => $labels,
'show_ui' => true,
'show_in_tag_cloud' => true,
'query_var' => true,
'rewrite' => array(
'slug' => 'production/year',
'with_front' => false,
),
);
register_taxonomy( 'productionyear', 'post_type_production', $args );
}