See my answer below; I cannot immediately accept it.
I made a custom post type of
register_post_type( 'sector', array( 'labels' => array( 'name' => __( 'Sectors' ), 'singular_name' => __( 'Sector' ) ), 'public' => true, 'has_archive' => false, 'rewrite' => array('slug' => 'sector') ) );
I have a sector called "Hotels & Hospitality" which resides at
site.com/sector/hotels-hospitality/. I have other sectors that reside at other URLs.
I also have a normal Page called "Sector" (which resides at
site.com/sector/) and a subpage called "Hotels & Hospitality" whose URL is also
At the moment, when I navigate to
site.com/sector/hotels-hospitality/ it's the post-type page that shows. Can I make it so that the normal Page shows instead? This is a special landing page for this sector.
I tried this in the functions.php of my theme:
flush_rewrite_rules(); add_rewrite_rule( 'sector/hotels-hospitality/', 'index.php?page_id=1700', // 1700 = post_id of the Page 'top' );
No luck so far! I have also tried it without the
'top' param and this seemed to make no difference.
After this I also edited the "Hotels & Hospitality" sector post type slug from
site.com/sector/hotels (thinking that that way, at least I would be able to see the other page),
but now when I go to
site.com/sector/hotels-hospitality/, I am redirected to
site.com/sector/hotels/ and I can't undo it! I tried resaving permalinks...
I then tried renaming the Page to
site.com/sector/hotels-hospitality-page/ and this is now going to a 404.
I am using a fresh install of Version 4.7.3.
@WebElaine helped me delete the redirect from
site.com/sector/hotels by deleting the _wp_old_slug field in wppostmeta.
site.com/sector/hotels-hospitality-page/ is still going to a 404.
site.com/index.php?page_id=1700 is redirecting to
site.com/sector/hotels-hospitality-page, giving a 404.
I guess the problem is the site is searching for a sector post with a slug of hotels-hospitality-page and not finding one... it's not getting as far as to check the pages.