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.
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.