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 with custom categories using the following:

add_action( 'init', 'create_post_type' );
function create_post_type() {
    register_post_type( 'products',
        array(
            'labels' => array(
                'name' => __( 'Products' ),
                'singular_name' => __( 'Product' )
            ),
        'capability_type' => 'post',
        'supports' => array('title','editor','comments'),   
        'public' => true,
        'has_archive' => true,
        'rewrite' => array( 'slug' => 'products' ),
        )
    );
}

function news_init() {
    // create a new taxonomy
    register_taxonomy(
        'products',
        'products',
        array(
            'label' => __( 'Product Categories' ),
            'sort' => true,
            'hierarchical' => true,
            'args' => array( 'orderby' => 'term_order' ),
            'rewrite' => array( 'slug' => 'products' )
        )
    );      
}
add_action( 'init', 'news_init' );

For some reason I just can't display the posts for specific categories. Can someone point me in the right direction?

I'm trying to goto the url /products/category/monitors for example but it displays a page not found. I've duplicated the archive.php template and renamed it category-monitors.php.

share|improve this question
    
custom post type and taxonomy with same slug - products ? try changing one of them –  amit Aug 13 '12 at 13:04
    
@amit Ok thanks, I've changed the taxonomy to products-category so would that make the url /products/products-category/monitors? If so that's giving a page not found as well. –  Rob Aug 13 '12 at 13:09
add comment

1 Answer

First check if custom post type + taxonomy archive displaying correct posts by visiting a url structure like this -

mysite.com/?post_type=products&products-category=monitors

If it's working then you can do some custom rewrite rules to show them just like you want.

Here are some recommended answers on WPSE describing same

share|improve this answer
    
Thanks. It's now loading a page but is displaying ALL the products rather than just the monitors. Is there a way to use a custom template for monitors and another template for other products? –  Rob Aug 13 '12 at 13:33
add comment

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.