0

I am using two post types:

a) Posts ( Default post type) also name as blog for blogging.

b) case studies ( Custom Post Type ) only for case studies.

I want to add the string ‘blog’ for default post type post and ‘casestudies’ for custom post type like:

example.com/blog/post-name/

example.com/casestudies/case-study-name/

right now i have selected /%postname%/ as my permalink structure. but it is only picking example.com/casestudies/case-study-name/ url for case study post type and for blog it is displaying example.com/post-name. when i change permalink to blog/%postname%/ it also changes url structure for case study post type as example.com/blog/casestudies/case-study-name/

Thanks in advance.

0

Permalink structure for blog posts and pages are managed in Wordpress Settings -> Permalinks page, so to make blog posts have permalinks like blog/%postname%/ and you've done it right.

The tricky part is about Custom Post type permalinks declaration:

in your CPT arguments declaration there's a rewrite rule parameters, which in turn has with_front - if this parameter is false you'll have permalink structure without prefix used for blog posts, and if it's true you'll have what you've experienced. By default it's set to true.

So fixed part of rewrite parameter will look like.

'rewrite' => array(
    'slug'       => 'casestudies', // your case studies permalink base.
    'with_front' => false, // important to make your links without base of blog posts.
    'pages'      => true, // set true if you need pagination for your cpt listing.
),
| improve this answer | |

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.