0

I have a custom post type called articoli-redazione. I would like to make archive url of this kind of post type to have a PAGE as parent as in this example:

https://mywebsite.it/page-name/custom-post-type-archive

The custom post type needs to be hierarchical.

Is that possible? Is there a way to have a custom rewrite?

Thank you!

3

Yes. First, unregister the post type. (None of the actual data will be deleted if you already have posts.) Then, re-register it with

'rewrite' => array('slug' => 'page-name/custom-post-type-archive')

This will set your archive at the URL you're looking for, and all the individual CPT posts will be "under" that - i.e. '/page-name/custom-post-type-archive/single-title/'.

3
  • Does this really work? I'm going to give it a go. – Robbiegod Sep 12 '20 at 18:20
  • HOT DOG! This totally works. You should totally accept this as the correct answer. Thank you @WebElaine for posting this. This is one of those little hidden gems about Wordpress that just makes it a joy to work with. – Robbiegod Sep 12 '20 at 18:30
  • After experimenting some more, there is one drawback to this method. That is if you are using YOAST breadcrumbs, the breadcrumbs don't output correctly as they think the posts is at the root instead of under the page. Any tips to handle that? – Robbiegod Sep 12 '20 at 19:28

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.