I have a CPT called “case-studies” and the slug of the archive page of this CPT is www.my-domain.com/case-studies and the slug of the CPT posts is www.my-domain.com/case-studies/case-study-name.

Now, for SEO purposes, I have to change the slug of the archive page to “testimonials-case-studies” so the slug for the “case-studies” archive page it has to be www.my-domain.com/testimonials-case-studies/ and the slug for the posts have to be www.my-domain.com/case-studies/case-study-name (same as before).

What is the best way or the solution for this?

What I have tried so far is:

  • creating a custom page template and change the slug of the page to /testimonials-case-studies/ and redirect /case-studies/ to /testimonials-case-studies/ but the posts www.my-domain.com/case-studies/case-study-name are not working because there is a problem with redirection.

  • Using:

    'rewrite' => array(
        'slug' => 'testimonials-case-studies',
        'with_front' => false
    ),
    

In the custom post type BUT the slug for the post change to www.my-domain.com/testimonials-case-studies/case-study-name but IT HAS to be: www.my-domain.com/case-studies/case-study-name

Is there a possible solution for this?

1
1

Pass the desired archive slug via has_archive:

$args = array(
    'rewrite'     => array( 'slug' => 'case-studies' ),
    'has_archive' => 'testimonials-case-studies',
);

Leave a Reply

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