How to rewrite slug of custom post type archive page

I have a CPT called "case-studies" and the slug of the archive page of this CPT is www.my-domaincase-studies

I have a CPT called "case-studies" and the slug of the archive page of this CPT is www.my-domain/case-studies and the slug of the CPT posts is www.my-domain/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/testimonials-case-studies/ and the slug for the posts have to be www.my-domain/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/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/testimonials-case-studies/case-study-name but IT HAS to be: www.my-domain/case-studies/case-study-name

Is there a possible solution for this?

I have a CPT called "case-studies" and the slug of the archive page of this CPT is www.my-domain/case-studies and the slug of the CPT posts is www.my-domain/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/testimonials-case-studies/ and the slug for the posts have to be www.my-domain/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/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/testimonials-case-studies/case-study-name but IT HAS to be: www.my-domain/case-studies/case-study-name

Is there a possible solution for this?

Share Improve this question edited Sep 29, 2019 at 21:26 wittich 1732 silver badges10 bronze badges asked Jul 5, 2018 at 16:03 andresglandresgl 1641 gold badge3 silver badges14 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 17

Pass the desired archive slug via has_archive:

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745120231a4612370.html

相关推荐

  • How to rewrite slug of custom post type archive page

    I have a CPT called "case-studies" and the slug of the archive page of this CPT is www.my-domaincase-studies

    6小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信