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 plugin free custom post type and taxonomy setup - see below. From this I get an archive of the CPT at:

/archives/nomination-archive

If I use the_terms( $post->ID, 'nomination_type' , ' ' ) I get a nice link to my taxonomy term archives in each of my nomination posts i.e:

/archives/nomination-type/best-2013

Going to this url gives me an archive page with a title "Best 2013" as you would expect, but I can't for the life of me get it to show any posts..refreshed permalinks etc etc

Any help much appreciated...

add_action( 'init', 'create_nomination_post_type' );
function create_nomination_post_type() {
    register_post_type( 'nomination',
        array(
            'labels' => array(
                'name' => __( 'Nominations' ),
                'singular_name' => __( 'Nomination' ),
                'add_new_item' => __( 'Add New Nomination' )
            ),
        'public' => true,
        'menu_position' => 6,
        'exclude_from_search' => true,
        'has_archive' => true,
        'rewrite' => array('slug' => 'nomination-archive'),
        'supports' => array( 
          'title', 
          'editor',
          'author',
          'thumbnail',
          'page-attributes'
           ),
        )
    );
}

//
// Add nominatons type taxonomy
//
function add_nomination_type_taxonomies() {
    register_taxonomy('nomination_type', 'nomination', array(
        // Hierarchical taxonomy (like categories)
        'hierarchical' => true,
        'labels' => array(
            'name' => _x( 'Nomination Categories', 'taxonomy general name' ),
            'singular_name' => _x( 'Nomination Categories', 'taxonomy singular name' ),
            'search_items' =>  __( 'Search Nomination Categories' ),
            'all_items' => __( 'All Nomination Categories' ),
            'parent_item' => __( 'Parent Nomination Categories' ),
            'parent_item_colon' => __( 'Parent Nomination Category:' ),
            'edit_item' => __( 'Edit Nomination Category' ),
            'update_item' => __( 'Update Nomination Category' ),
            'add_new_item' => __( 'Add New Nomination Category' ),
            'new_item_name' => __( 'New Nomination Category Name' ),
            'menu_name' => __( 'Nomination Item Categories' )
        ),
         //Control the slugs used for this taxonomy
        'rewrite' => array(
            'slug' => 'nomination-type' // This controls the base slug that will display before each term
          //    'with_front' => true, // Don't display the category base before "/genres/"
            //'hierarchical' => false // Allows good urls
        )
    ));
}
add_action( 'init', 'add_nomination_type_taxonomies', 0 );
share|improve this question

1 Answer 1

I may be an idiot - not sure. Probably indicates I am.

Setting 'exclude_from_search' to 'false' for the CPT clears up this problem.

Still not quite sure why the CPT archive works and the taxonomy ones do not when 'exclude_from_search' is 'true' but there you go.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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