Custom post type slug conflicts with another post type

this is driving me nuts.

I have two custom post types

register_post_type( 'products',
    array(
        'labels' => array(
            'name' => __( 'Products' ),
            'singular_name' => __( 'Product' )
        ),
        'public' => true,
        'has_archive' => true,
        'rewrite' => array('slug' => 'products'),
    )
);

register_post_type( 'markets',
    array(
        'labels' => array(
            'name' => __( 'Markets' ),
            'singular_name' => __( 'Market' )
        ),
        'public' => true,
        'has_archive' => true,
        'rewrite' => array('slug' => 'markets'),
    )
);

and two templates (archive-products.php and archive-markets.php)

The products custom type works. The archive page displays correctly, but the single page doesn’t display. If I remove the register_post_type for markets the single page for products works.

The markets type however has the url of www.website.com/products/a-market-post which is really weird as it’s using the slug from the products post type.

Does anyone know what might be happening? I’ve refreshed the permalinks page 1000 times and that doesn’t do anything.

Cheers!

Read more here: Custom post type slug conflicts with another post type

Leave a Reply

Your email address will not be published. Required fields are marked *