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
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
You must be logged in to post a comment.
You can do this with a rewrite rule from within WordPress. Take a look at the documentation for
add_rewrite_rule
.Something like this:
You can stick that in a plugin.
The downside here is that this is not very portable. You assume that the “Photos” category slug will always be
photos
, which might not be true on all WP installs. If this is something for yourself, that’s not a big deal — you can be sure that everything works out the way you need it to. If it’s something you’re going to use with clients or release publicly, you’ll need to do more to make it flexible. Like add an admin page where folks can select the category that the/photos
base rewrites to, for instance.You can change the Category Base in Settings -> Permalinks to:
or
However these solutions don’t always work properly.
You can also try adding a rewrite rule to your .htaccess file: