Permalinks for CPT breaks permalinks to pages

I have a CPT that I would like to have the ‘root’-permalinks:

So for the page: ‘Foo Bar’ I would like that to have the URL:

https://example.org/foo-bar

I’ve found out that I achieve this by registering the CPT with the following line in the args for register_post_type( 'my_CPT', $args );:

'rewrite' => array('slug' => "https://wordpress.stackexchange.com/", 'with_front' => false)

However… When I add that, then my permalinks for my pages don’t work. I would ideally give them these permalinks:

https://example.org/page/some-page

How do I do that?

2 Answers
2

Pages are hardcoded to be the default parsing possibility to any URL (or to say it differently, if nothing else matches, wordpress will try to find a page there).

Therefor it is unwise to put permalink structure with no “prefix”, but if you really want it that way, just add a page with a “page” slug and make all other pages its sons. This will work great if you do not have many pages and you will have zero code that hacks at parsing and permalink generation to worry about 😉

Leave a Comment