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.com/blog/post-name/ b) example.com/program/program-name/

Thanks in advance.

  • 1
    This is controlled by your post type registration code, please edit your question and add your code. – Milo Dec 10 '18 at 14:04

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.

| improve this answer | |
  • "In your case, setting with_front to false for your CPT should solve your problem." This point help me and fix my issue. Thanks foir help. As I am new here so plz let em know how can I make it solved! – Pardeep Singh Dec 11 '18 at 8:47
  • @PardeepSingh You have to click on the tick sign near the answer that helped you. meta.stackexchange.com/q/5234 – Krzysiek Dróżdż Dec 11 '18 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.