Faking “Same Slug Root, Multiple Custom Post Types” with Redirects?

Question

I know you can’t have:

/my-cpt1/name-of-post-1/

and

/my-cpt2/name-of-post-2/

both live at:

/my-ideal-root/name-of-post-1/
/my-ideal-root/name-of-post-2/

But I have a situation where I have content that must be differentiated into different custom post types (because of where it is used elsewhere), that I would like to also be represented on the front end as living under one root path, let’s say that’s /rules/. Let’s also say that I can guarantee /rules/ won’t be occupied by anything else (that is, I won’t put a page there or any other content under it).

Is it possible to somehow redirect:

/my-cpt1/name-of-post-a/
/my-cpt2/name-of-post-b/
/my-cpt3/name-of-post-c/…

and so on to:

/potato/name-of-post-a/
/potato/name-of-post-b/
/potato/name-of-post-c/

Maybe after each CPT resolves to its default URL /my-cpt-1/whatever/, I can redirect it to the /rules/my-cpt-1/whatever, and render content in a template at that path, pulling the data based on /whatever/ from the correct CPT (/my-cpt-1/) in the path?

0
alkah3st 4 months 2021-06-24T00:10:10-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse