Hey all first off im a WP newbie so go easy!

Ive been searching for a couple of days now to see if I can find the answer to this but cant get anything definitive.

I have a custom post type called 'documents' and a corresponding archive called archive-documents.php. When I click on a custom taxonomy it displays my custom posts in the default archive.php template.

Rather than trying to explain more here is the code in functions.php

add_action('init', 'documents_register');

function documents_register() {

$labels = array(
    'name' => _x('Documents', 'post type general name'),
    'singular_name' => _x('Document', 'post type singular name'),
    'add_new' => _x('Add New', 'Document Entry'),
    'add_new_item' => __('Add New Document Entry'),
    'edit_item' => __('Edit Document Entry'),
    'new_item' => __('New Document Entry'),
    'view_item' => __('View Document Entry'),
    'search_items' => __('Search Documents'),
    'not_found' =>  __('Nothing found'),
    'not_found_in_trash' => __('Nothing found in Trash'),
    'parent_item_colon' => ''

$args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true,
    'query_var' => true,
    'menu_icon' => get_stylesheet_directory_uri() . '/images/documents-icon.png',
    'rewrite' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'menu_position' => null,
    'rewrite' => array( 'slug' => 'documents' ),
    'has_archive' => true,
    'supports' => array('title','editor','thumbnail'),


register_post_type( 'documents' , $args );

register_taxonomy("types", array("documents"), array("hierarchical" => true, "label" => "Types", "singular_label" => "Type", "rewrite" => true));


  • 2
    have you tried flushing the rewrite rules (by going to the permalinks settings page & clicking save)? also (sorry, this bit isn't an answer to your question, just me being picky!), i find it more logical to follow the convention of naming custom post types using the singular noun (as used in core for "post" & "page"). "type" is also a reserved term in WordPress so you shouldn't use that for your taxonomy. Jan 27 '13 at 0:31
  • @SimonBlackbourn Thanks so much! Post this as an answer and hopefully OP will mark it as best answer
    – Danger14
    Jun 17 '14 at 18:00

When you're viewing a Custom Post Type Archive, your archive-documents.php template will be used. In your case this is the URL /documents/.

When you're viewing a taxonomy term, you're viewing a Custom Taxonomy Archive, not a Custom Post Type Archive. If you haven't created one specific to your taxonomy, then archive.php (or index.php, if archive.php doesn't exist) will be used.

You want to create a template named taxonomy-types.php to display the posts in your custom taxonomy.

See the Template Hierarchy for more info.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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