WordPress: Remove Category From The URL

Here there is a method that will edit out the category/ url structure that wordpress ads by default.
Instead of “www.yourweb.com/category/worpress-notes/”
It will read “www.yourweb.com/wordpress-notes/”

First of all:

Under Custom Structure type:


And Save.

Then, go to:

Add the following code at the end of your functions.php file.

add_filter('user_trailingslashit', 'remcat_function');
function remcat_function($link) {
return str_replace("/category/", "/", $link);

add_action('init', 'remcat_flush_rules');
function remcat_flush_rules() {
global $wp_rewrite;

add_filter('generate_rewrite_rules', 'remcat_rewrite');
function remcat_rewrite($wp_rewrite) {
$new_rules = array('(.+)/page/(.+)/?' => 'index.php?category_name='.$wp_rewrite->preg_index(1).'&paged='.$wp_rewrite->preg_index(2));
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;

Thanks to WebDevTuts.com

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>