Custom Post Type and Taxonomy combination

// Add the new post_type and taxonomy
add_action('init', function(){
    // Add a post_type named 'testype'
    register_post_type($postype="testype", $arguments = array(
        'name'                  => $postype,
        'label'                 => 'Test',
        'public'                => true,
        'exclude_from_search'   => true,
        'capability_type'       => 'post',
        'supports'              => array(
            'title', 'excerpt', 'editor', 'custom-fields', 'comments',
        ),
        'show_in_nav_menus'     => false,
        'hierarchical'          => false,
        'publicly_queryable'    => true,
        'rewrite'               => array(
            'with_front'    => false,
            'pages'         => true,
            'feeds'         => true,
            'slug'          => 'test/read',
            // This is my custom work, not stock functionality
            // 'permastruct'    => '%id%'
        ),
        'query_var'             => 'testing',
        'has_archive'           => true,
        'show_ui'               => true,
        'can_export'            => true,
        '_builtin'              => false,
    ));
    register_taxonomy($postax = 'testax', $postype, array(
        'label'         => 'Tax',
        'hierarchical'  => false,
        'rewrite'       => array(
            'with_front'        => false,
            'pages'             => true,
            'feeds'             => true,
            'slug'              => 'test/browse',
        ),
        'public'            => true,
        'show_ui'           => true,
        'query_var'         => true,
        'show_in_nav_menus' => true,
        'show_tagcloud'     => false,
    ));
});
// Add the 'snippet' postype to the loop.
add_action('pre_get_posts', function(\WP_Query $query){
    if(!is_archive()) return; // Only for archives!
    // If suppress_filters is on, bail here :) (no idea what this really does)
    if(!empty($query->query_vars['suppress_filters'])) return;
    // Add a new post type to the loop if we are visiting the archive
    // of a taxonomy assigned to the post.
    if(!empty($query->query_vars['testax'])){
        $post_types = $query->get('post_type');
        if(empty($post_types)) $post_types = array('post');
        elseif(is_string($post_types)) $post_types = array($post_types);
        // Add the new post_type now
        $query->set('post_type', array_merge($post_types, array('testype')));
    }
    return;
});

Cheers! This is fully functional and commented. It has PHP 5.3 syntax as I don’t do 5.2 anymore and I’m also sort of lazy. I’m sure you can handle the function extraction if you still use 5.2.

Let me know how it goes, and if you have questions.

tech