ThemeShaper Forums » Thematic


Taxonomy Archive Page returns 404

(3 posts)
  • Started 9 years ago by wlanni
  • Latest reply from middlesister
  • This topic is not resolved
  1. wlanni


    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' ),
    	    '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',
    			'publicly_queryable' => true,
    			'capability_type' => 'post',
    			'query_var' => true,
    			'rewrite' => array('slug'=>'explore-the-era/locations', 'with_front' => true),
            	'has_archive' => true,
    			'labels' => $labels,
    			'show_in_nav_menus' => true,

    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.

    Posted 9 years ago #
  2. I hope you're not still stuck on this, but if so then update your permalinks. It's caught me out a few times today already.

    Posted 9 years ago #
  3. middlesister

    Maybe I am missing something, but isn't this expected behaviour?

    A custom taxonomy is a new way to label your posts, just as categories and tags are two built-in taxonomies. The template category.php is the template for displaying the terms (the actual named categories) in the taxonomy "category". In the same way, your template file taxonomy-venues.php is the template for displaying the terms (art school, gallery etc) in your taxonomy "venue".

    With permalinks set, will use category.php but will return 404 not found, just like for your taxonomy. I think wordpress is looking for a Page with the slug of 'category', or 'venues' in this case.

    The way to list the categories (all the terms in the taxonomy "category") is to use wp_list_category(). Similarly, you can list all your venues (the terms in your taxonomy "venues") with

    $args = array(
        'taxonomy' => 'venues'
    wp_list_category( $args );

    What kind of listing were you expecting? Maybe you would need a custom query and loop instead.

    Posted 9 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.