Hello,
I'm adding Taxonomies via code, registering them in my functions.php. When I enter the taxonomy in as a url, (not a term, but the taxonomy itself), I get a 404.
This occurs even with a custom taxonomy-x.php page.
For example, I created a "venues" taxonomy:
//Add venues TAXONOMY!!!
function create_venues_taxonomy() {
$labels = array(
'name' => _x( 'Venues', 'taxonomy general name' ),
'singular_name' => _x( 'Venue', 'taxonomy singular name' ),
'search_items' => __( 'Venues' ),
'all_items' => __( 'All Venues' ),
'parent_item' => __( 'Parent Venue' ),
'parent_item_colon' => __( 'Parent Venue:' ),
'edit_item' => __( 'Edit Venue' ),
'update_item' => __( 'Update Venue' ),
'add_new_item' => __( 'Add New Venue' ),
'new_item_name' => __( 'New Venue Name' ),
'menu_name' => __( 'Venues' ),
);
register_taxonomy(
'venues',
'',
array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array('slug'=>'explore-the-era/venues','with_front' => false),
'has_archive' => true
)
);
}
add_action( 'init', 'create_venues_taxonomy', 0 );
I then create several terms for the taxonomy in the backend, like "Art Schools" and "Galleries".
I create a custom post type called Locations:
function create_pst_locations() {
$labels = array (
'name' => _x('Locations', 'post type general name'),
'singular_name' => _x('Location', 'post type singular name'),
'add_new' => _x('Add New', 'Location'),
'add_new_item' => __('Add New Location'),
'edit_item' => __('Edit Location'),
'new_item' => __('New Location'),
'view_item' => __('View Location'),
'search_items' => __('Search Locations'),
'not_found' => __('No Locations found'),
'not_found_in_trash' => __('No Locations found in Trash'),
'parent_item_colon' => '',
);
$supports=array('title', 'editor', 'custom-fields', 'revisions', 'excerpt', 'author', 'thumbnail');
$taxonomies = array('neighborhoods','decades','venues');
register_post_type( 'location',
array(
'hierarchical'=>false,
'publicly_queryable' => true,
'capability_type' => 'post',
'query_var' => true,
'rewrite' => array('slug'=>'explore-the-era/locations', 'with_front' => true),
'has_archive' => true,
'labels' => $labels,
'public'=>true,
'menu_position'=>22,
'supports'=>$supports,
'taxonomies'=>$taxonomies,
'show_in_nav_menus' => true,
)
);
}
add_action('init','create_pst_locations');
I then create several Location posts, and attach different Venues (art school, gallery, etc) to those post.
I then created a taxonomy-venues.php, a copy of my taxonomy.php
I try to navigate to /explore-the-era/venues
and I get a 404.
However, if I navigate to /explore-the-era/venues/art-schools I get a listing of the posts that have been assigned to Venues / Art Schools.