$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>categories - Remove category link|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

categories - Remove category link

matteradmin8PV0评论

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(); }
}

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far