categories - Remove category link

admin2025-06-06  2

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

/

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

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

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

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

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

http://example/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.

Share Improve this question edited Sep 25, 2013 at 14:14 fuxia 107k39 gold badges255 silver badges461 bronze badges asked Sep 25, 2013 at 13:34 LucasLucas 1054 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 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(); }
}
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749142356a316726.html

最新回复(0)