Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rewrite category wordpress

Is it possible to rewrite only one category ?

I have a category "Photos" and just for this category.

I just want to rewrite it from /category/photos to /photos

like image 606
Steffi Avatar asked Oct 23 '22 09:10

Steffi


1 Answers

You can do it with WP Rewrite API. Add this to functions.php

add_action('init', 'register_rewrites');
function register_rewrites() {
   add_rewrite_rule('^photos$', 'index.php?category_name=photos','top');
}

Remember to reload your rewrite settings: go to Settings -> Permalinks and click on Save button - no changes needed.

like image 193
fandasson Avatar answered Dec 13 '22 20:12

fandasson