$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>permalinks - Rewrite Rule for default post type|Programmer puzzle solving
最新消息: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)

permalinks - Rewrite Rule for default post type

matteradmin9PV0评论

I am using two post types into my site: a) Post ( default post type ) b) Program ( Custom Post Type ) I am trying to add '/blog/' string to default post type URL. If I am tying to do it from permalink option in admin panel then it will aslo add the string to Program post type but I want it as following:

a) example/blog/post-name/ b) example/program/program-name/

Thanks in advance.

I am using two post types into my site: a) Post ( default post type ) b) Program ( Custom Post Type ) I am trying to add '/blog/' string to default post type URL. If I am tying to do it from permalink option in admin panel then it will aslo add the string to Program post type but I want it as following:

a) example/blog/post-name/ b) example/program/program-name/

Thanks in advance.

Share Improve this question asked Dec 10, 2018 at 13:11 Pardeep SinghPardeep Singh 232 bronze badges 1
  • 1 This is controlled by your post type registration code, please edit your question and add your code. – Milo Commented Dec 10, 2018 at 14:04
Add a comment  | 

1 Answer 1

Reset to default 1

When you register your custom post type using register_post_type function, you have to be very careful with rewrite param.

You should pass an array with following keys:

  • slug => string Customize the permalink structure slug. Defaults to the $post_type value. Should be translatable.
  • with_front => bool Should the permalink structure be prepended with the front base. (example: if your permalink structure is /blog/, then your links will be: false->/news/, true->/blog/news/). Defaults to true
  • feeds => bool Should a feed permalink structure be built for this post type. Defaults to has_archive value.
  • pages => bool Should the permalink structure provide for pagination. Defaults to true
  • ep_mask => const As of 3.4 Assign an endpoint mask for this post type. For more info see Rewrite API/add_rewrite_endpoint, and Make WordPress Plugins summary of endpoints. If not specified, then it inherits from permalink_epmask(if permalink_epmask is set), otherwise defaults to EP_PERMALINK.

In your case, setting with_front to false for your CPT should solve your problem.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far