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 post type that uses a custom taxonomy. It's working, from what I can tell, in the sense that I can create a post, and assign the custom taxonomy terms to it. Debugging shows the terms are being saved.

I guess my confusion lies in how the template hierarchy works. I copied the archive.php file and called it "taxonomy-zouk_video_level.php" and it's being called. But that file has the usual Loop in it, and no posts are found when I navigate to the URL for the term.

Am I supposed to be using a different Loop? Or am I not to use the Loop at all?

Here's my custom post type code:

<?php

function zouk_custom_types() { 

    $videolabels = array(
        'name'               => 'Videos',
        'singular_name'      => 'Video',
        'add_new'            => 'Add New',
        'add_new_item'       => 'Add New Video',
        'edit_item'          => 'Edit Video',
        'new_item'           => 'New Video',
        'all_items'          => 'All Videos',
        'view_item'          => 'View Video',
        'search_items'       => 'Search Videos',
        'not_found'          => 'No Videos found',
        'not_found_in_trash' => 'No Videos found in Trash',
        'parent_item_colon'  => '',
        'menu_name'          => 'Videos'
    );

    register_post_type( 'zouk_video',
        array( 
            'labels' => $videolabels,
            'description' => __( 'A video.', 'bonestheme' ),
            'public' => true,
            'publicly_queryable' => true,
            'exclude_from_search' => true,
            'show_ui' => true,
            'query_var' => true,
            'menu_position' => 1,
            'menu_icon' => 'dashicons-editor-video', 
            'rewrite'   => array( 'slug' => 'zouk_video', 'with_front' => false ), 
            'has_archive' => 'zouk_video',
            'capability_type' => 'post',
            'hierarchical' => false,
            'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions')
        )
    ); 

    $instructorlabels = array(
        'name'               => 'Instructors',
        'singular_name'      => 'Instructor',
        'add_new'            => 'Add New',
        'add_new_item'       => 'Add New Instructor',
        'edit_item'          => 'Edit Instructor',
        'new_item'           => 'New Instructor',
        'all_items'          => 'All Instructors',
        'view_item'          => 'View Instructor',
        'search_items'       => 'Search Instructors',
        'not_found'          => 'No Instructors found',
        'not_found_in_trash' => 'No Instructors found in Trash',
        'parent_item_colon'  => '',
        'menu_name'          => 'Instructors'
    );

    register_post_type( 'zouk_instructor', 
        array( 
            'labels' => $instructorlabels, 
            'description' => __( 'An instructor.', 'bonestheme' ),
            'public' => true,
            'publicly_queryable' => true,
            'exclude_from_search' => true,
            'show_ui' => true,
            'query_var' => true,
            'menu_position' => 2,  
            'menu_icon' => 'dashicons-groups', 
            'rewrite'   => array( 'slug' => 'zouk_instructor', 'with_front' => false ), 
            'has_archive' => 'zouk_instructor',
            'capability_type' => 'post',
            'hierarchical' => false,
            'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions')
        ) 
    ); 

    /* use categories with the videos */
    register_taxonomy_for_object_type( 'category', 'zouk_video' );

}

    // adding the above to the Wordpress init
    add_action( 'init', 'zouk_custom_types');

function zouk_video_types() {   

    // now custom term for video levels
    register_taxonomy( 'zouk_video_level', 'zouk_video',
        array(
            'hierarchical' => true,
            'label' => 'Video Levels',
            'show_admin_column' => true, 
            'show_ui' => true,
            'query_var' => true,
            'rewrite' => array( 'slug' => 'video-level' ),
            'public' => true,
        )
    );

}

// adding the above to the Wordpress init
    add_action( 'init', 'zouk_video_types');

?>
share|improve this question
1  
taxonomy-my_custom_type.php this makes no sense since there is no template in hierarchy combining taxonomy with custom post type. Which archive you are talking about precisely? What is your archive file name literally? –  Rarst Jan 19 at 23:59
    
Sorry, you're right, was a typo. I edited the question to include the correct template name: "taxonomy-zouk_video_level.php". –  Mike Jan 20 at 11:08

1 Answer 1

Turns out I needed to do this:

'exclude_from_search' => false

Now the Loop is returning posts.

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.