Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom taxonomy, artist, that is related to three custom post types: videos, posts and letters. I have an taxonomy-artist.php template that should display the archive for a given artist.

When I visit /artist/ARTIST_NAME it will display the taxonomy archive template only if there are no other posts associated with it. If there are posts associated with it, you get redirected to an individual post (I believe it's the oldest post associated with the taxonomy term). So if I visit /artist/ARTIST_NAME and there is content associated with it, I get kicked out to [videos|letters|posts]/THE_POST_NAME.

I saw something about needing to have taxonomies registered before custom post types, so I am registering the taxonomy first and I've flushed out my permalink settings, but no luck. I'm stumped as to why this would be happening, so I would appreciate any ideas about what would cause this!

Here's the code I'm using for registering the taxonomy and post types:

register_taxonomy( 'artist',
    array(
        'videos',
        'letters',
        'post'
    ),
    array(
        'labels' => array(
            'name' => _x( 'Artists', 'taxonomy general name' ),
            'singular_name' => _x( 'Artist', 'taxonomy singular name' ),
            'search_items' =>  __( 'Search Artists' ),
            'all_items' => __( 'All Artists' ),
            'parent_item' => __( 'Parent Artist' ),
            'parent_item_colon' => __( 'Parent Artist:' ),
            'edit_item' => __( 'Edit Artist' ),
            'update_item' => __( 'Update Artist' ),
            'add_new_item' => __( 'Add New Artist' ),
            'new_item_name' => __( 'New Artist Name' ),
            'menu_name' => __( 'Artists' ),
        )
    )
);

register_post_type( 'letters',
    array(
        'labels' => array(
            'name' => __( 'Letters' ),
            'singular_name' => __( 'Letter' )
        ),
        'public' => true,
        'has_archive' => true,
        'supports' => array( 'title', 'editor', 'thumbnail' ),
        'menu_icon' => get_stylesheet_directory_uri() . '/img/mail.png',
    )
);

register_post_type( 'videos',
    array(
        'labels' => array(
            'name' => __( 'Videos' ),
            'singular_name' => __( 'Video' )
        ),
        'supports' => array( 'title', 'editor', 'thumbnail' ),
        'public' => true,
        'menu_icon' => get_stylesheet_directory_uri() . '/img/blue-document-film.png',
    )
);
share|improve this question
    
Can you post your relevant register_post_type(), register_taxonomy(), and register_taxonomy_for_object_type() code? –  Chip Bennett Dec 20 '12 at 12:55
    
Sure thing @ChipBennett! I just updated the question with the code that is registering the taxonomies and post types. –  Chris Schmitz Dec 20 '12 at 14:35
    
Does anything change if you disable rewrites (use default permalinks)? –  Chip Bennett Dec 20 '12 at 14:51
    
@ChipBennett - Nope. I just tried it and it still kicks me out to a single post when visiting a taxonomy archive page. –  Chris Schmitz Dec 20 '12 at 14:58
    
Other things to try: call register_taxonomy() after register_post_type(); add taxonomy support inside the register_post_type() call itself (though I doubt either of these is the issue, if you are able to apply the taxonomy to all applicable post types); for testing purposes, apply the taxonomy only to one custom post type, and then see if the taxonomy archive index works as expected. –  Chip Bennett Dec 20 '12 at 15:13
show 1 more comment

closed as too localized by Rarst Jan 12 '13 at 16:17

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers

Finally figured this out. It turns out the original author of the theme was overriding this. My setup was correct, I just had to remove the overrides.

share|improve this answer
add comment

Taxonomy archive index pages for custom taxonomies are not rendered using archive-{taxonomy}.php, but rather, using taxonomy-{taxonomy}-{term}.php, which falls back to taxonomy-{taxonomy}.php, which falls back to taxonomy.php. Refer to the Template Hierarchy.

WordPress interprets archive-{foobar}.php as archive-{post-type}.php, and would use that template to render the archive index for the foobar post-type. So, your artist taxonomy archive index page will never be rendered using archive-artist.php.

Try renaming the template file to taxonomy-artist.php.

share|improve this answer
    
Crap, I'm sorry... I actually am using taxonomy-artist.php, I just wasn't thinking. I will revise my question. Thanks for your help! –  Chris Schmitz Dec 20 '12 at 4:16
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.