WP - URL rewrite - custom post type/parent conflict

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?

Answers


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.

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


Need Your Help

GPS tracking and accelerometer

android gps accelerometer

Do you think it's a good idea to check the accelerometer for movement in order to save battery when running a service which checks and sends GPS location? Or is the onLocationChanged method optimiz...