0

I am looking for having custom post types and "categories" (limited, known, and just only one) for post. I want the following URLs:

site.com/cpt (archive of all the posts inside custom post type) site.com/cpt/cat1 (archive of all the posts inside custom post type and category cat1) site.com/cpt/cat2 (archive of all the posts inside custom post type and category cat2)

I know how to achieve the first but not the sencond and third. Thanks for your help.

  • So to clarify, you want to use the core category taxonomy, or you'll be registering your own for your CPT? – TheDeadMedic Jun 27 '16 at 12:58
  • I don't mind having to register ony taxonomy. Whatever the best approach will be for the situation. – Mario Jun 27 '16 at 16:09
  • Well, one involves a lot of convoluted hacking. The other involves registering a custom taxonomy ;) – TheDeadMedic Jun 27 '16 at 16:13
  • I am registering a custom taxonomy but I don't know how to achieve what I've written in the question. – Mario Jun 27 '16 at 23:44
0

Just use the slug component of your rewrite argument for your custom taxonomy:

register_taxonomy([
    'rewrite' => [
        'with_front' => false,
        'slug'       => 'cpt',
    ],

    // Other args
]);
  • Doing so if inside my taxonomy I have a "catagory" named cat1, I am not getting the posts with that category in the url 'cpt/cat1'. In fact, I cannot get the posts within the category :( – Mario Jun 27 '16 at 23:43

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.