One interesting case I’ve come up against a couple times how difficult it can be to have a custom post type url be the root. That is, and ignore the practicality of this specific example, if I have a Staff CPT, and I want the url structure to be example.com/staff-slug.
If you set rewrite[‘with_front’] to false, that doesn’t do it. If you set the rewrite slug to ‘’ or ‘/’, it’s likely to cause issues with pages. The workaround I’ve done (and only for CPT’s I know will have a low post count) is to generate a rewrite for each post. This does work.
But here’s what confuses me. The way WP does it is it matches the url to the first rewrite and gives it dibs. So, left to itself, the page rewrite matches the root url and it searches for a page by that slug. If not found, 404.
Rather than fighting over rewrite order in the giant rewrite array, wouldn’t it make sense to attach multiple post types so a single rewrite expression? That is, tell WP “I want the root url to first search the Staff CPT, and then pages. If the slug matches neither, then 404.”
What do you all think?