admin管理员组文章数量:1130349
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
1 Answer
Reset to default 1When 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.
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
1 Answer
Reset to default 1When 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.
本文标签: permalinksRewrite Rule for default post type
版权声明:本文标题:permalinks - Rewrite Rule for default post type 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749110997a2317385.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论