2

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
    Simply put, you can't have pages, a custom post type and a taxonomy all share a common URL, that's simply beyond what the rewrite rules are capable of handling. Put it this way, if i request example.com/paintings/something, how could WordPress know if i'm referring to a page, a post type or a taxonomy? (it can't). – t31os Mar 30 '11 at 13:03
  • I realised there are conflicts in trying to get that structure the way I have it currently, but I was hoping to do it another way. Can I have a taxonomy hierarchy thus: /paintings/landscape/painting-title/ and not have a page called 'paintings' is that possible? if so how should I go about it? – Andy Mar 30 '11 at 14:26
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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.