0

I want to use categories but I also want to remove the category pages.

http://www.example.com/categories/foo/

Assumed that this category exists this URL should return a 301 and redirect to

http://example.com/index.php

I've tried to add a category.php to my theme but this won't work for me.

I don't want to hide posts with a specific category or remove the category base or something like that. I'm using WordPress 3.6.1.

1

Hook 'template_redirect' action hook and redirect if in category using wp_redirect

add_action('template_redirect', 'no_cat_archives');

function no_cat_archives() {
  if ( is_category() ) { wp_redirect( home_url(), 301 ); exit(); }
}

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.