custom post type and custom taxonomy url conflict

I have custom post type called paintings and it has a custom taxonomy called paintings_category.

Currently I have this situation:

  • example.com/paintings/

    A page using page-paintings.php

  • example.com/paintings_category/landscape/

    Lists all landscape items in taxonomy.php

  • example.com/paintings/landscape/painting-title/

    Displays single painting post types, eg. single-paintings.php

If I try changing the slug as below, I get a 404 error on:

example.com/paintings/landscape/painting-title/

register_taxonomy( 
    'paintings_category', array('paintings'), 
    array( 
        'hierarchical' => true, 
        'label' => 'Categories', 
        'singular_label' => 'Category', 
        'rewrite' => array( 'slug' => 'paintings' )
    )
);

I’d like behaviour to be:

  • example.com/paintings/

    ideally list paintings_category as links

  • example.com/paintings/landscape/

    lists all items of landscape taxonomy

  • example.com/paintings/landscape/painting-title/

    displays single item

Any thoughts on how I can achieve this?

I tried adding paintings as a parent of landscape category in paintings_category but this still leaves me with a 404 on the single.

1 Answer
1

Well, it turns out it is indeed possible : )

I eventually found most of the answer in this post: Custom post types, taxonomies, and permalinks

Then I got single-paintings.php to paginate within selected taxonomy with this plugin: Ambrosite Next/Previous Post Link Plus (which looks like it could be dropped into functions.php if you wanted to do it without plugins).

Hope this helps someone!

Leave a Comment