Custom slugs for custom post types are interfering with custom page template for archive

[ad_1]

I have a custom post type of ‘treatment’ on my site. I want the url to be (for a single CPT): mysite.com/treatments/name-of-treatment

If I use a function eg:

add_filter( ‘register_post_type_args’, ‘wpse247329_register_post_type_args’, 10, 2 );
function wpse247329_register_post_type_args( $args, $post_type ) {

if ( ‘treatment’ === $post_type ) {
$args[‘rewrite’][‘slug’] = ‘treatments’;
}

return $args;
}

then my page (mysite.com/treatments) no longer uses the custom page template I have set up for it; it just defaults to a normal standard layout for an Archive page.

Any ideas how to stop affecting the custom page template when I rewrite the slug for the singular CPT?

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer