最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Custom post type with slug for plural (archive) and for single

matteradmin9PV0评论

I've been searching a way to have kind of "two" slugs for a custom post, let me give an example:

www.mywebsite/articles/ or www.mywebsite/articles/page/2/ for the archive
www.mywebsite/article/%post-name%/ for the single custom post

I've been searching a way to have kind of "two" slugs for a custom post, let me give an example:

www.mywebsite/articles/ or www.mywebsite/articles/page/2/ for the archive
www.mywebsite/article/%post-name%/ for the single custom post
Share Improve this question asked Nov 1, 2018 at 2:52 Rodrigo ButzkeRodrigo Butzke 17513 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 11

Both of these are controlled by the arguments passed to register_post_type, specifically, the rewrite and has_archive arguments:

$args = [
    'rewrite' => ['slug' => 'article'],
    'has_archive' => 'articles',
    // the rest of your arguments...
]
Post a comment

comment list (0)

  1. No comments so far