Question

I've been having trouble with this for a day now and can't seem to find a solution (it's probably blatantly obvious I just can't find/see it).

I have a custom post type called product where:

'rewrite' => array( 'slug' => 'product' )

So the posts that I create for that post type have the URLs:

  • example.com/product/first-product
  • example.com/product/second-product
  • example.com/product/third-product

etc..

I've also got a page created called Product Info that has the URL:

  • example.com/product

I'd like to create a page that has Product Info as its parent and therefore has the URL example.com/product/newpage

For me this returns a 404 page not found, I'm guessing this is because WordPress rewrites the URL and checks the product post type for newpage and cannot find it.

How do you do this without WordPress giving a 404 Page Not Found?

Was it helpful?

Solution

It's a conflict of slugs.

You will get conflicts if you have the same slug for a page and a CPT that uses that too. So for you, your CPT is using 'product', and your page is too. That's conflicting and causing the 404.

Rename your page Product Info page' slug to product-info.

enter image description here

For safety purposes flush your permalink cache by setting them to Default, saving, then saving them as what you had previously.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top