Custom Post Type slug same as page name causing a conflict

I have a Custom Post Type all set up. I would like the slug to be the same as a page name, because all of these CPT’s will be queried on that particular page (/team-members).

If I set the Custom Post Type slug to the page URL, that particular page doesn’t load the page template anymore. It loads a broken post template.

My Custom Post Type rewrite:

$rewrite = array(
‘slug’ => ‘team-members’,
‘with_front’ => false,
‘pages’ => false,
‘feeds’ => false,
);

This allows me to generate the proper URL of: http://www.example.org/team-members/bob-jones

The problem now is when I try to access the page: http://www.example.org/team-members/, it does not render the correct page template file (aptly titled page-team-members.php). Saving permalink settings didn’t work.

How can I create the URL slug of my Custom Post Type to not interfere with a page titled the exact same thing?

Read more here:: Custom Post Type slug same as page name causing a conflict

Leave a Reply

Your email address will not be published. Required fields are marked *