0

I wanted to make all my blog posts sit under a parent directory of /blog/ in the url's, so /my-great-article becomes /blog/my-great-article.

I did this by changing my permalink settings to /blog/%postname%/ which has worked fine.

However, I used to have two custom posts types, on the urls /case-studies/ and /events/ but now I can only access these by prefixing them with /blog/ ie. /blog/case-studies/ and /blog/events/.

I've been looking at rewrite rules for this, and I got this close, but no joy:

add_action( 'init', 'add_rewrite_rules' );
function add_rewrite_rules() { 
    add_rewrite_rule( '^case-studies(.*)$', 'index.php?post_type=case-studies', 'top' );
}

Can anyone please tell me where I'm going wrong? I feel like I might be close, possibly.

Your Answer

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

Browse other questions tagged or ask your own question.