WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I a add forward slash on categories URLs and serve only that version of a category (meaning URLs not ending in forward-slash will redirect to URLs ending in forward slash).

I manage to remove the category base using the "WP No Category Base" plugin but I need to add a forward slash on the category URL.


www.example.com/es  <- this is a category (needs a forward-slash '/')

www.example.com/es/hola.html <- this is a post so, it's ok, no changes needed.

The plugin Permalink Trailing Slash Fixer doesn't solve the problem here.

share|improve this question
up vote 3 down vote accepted

Filter category_link so WordPress creates slashed URLs for categories, and redirect_canonical so it accepts those URLs:

add_filter( 'category_link', 'wpse_71666_trailingslash_cat_url' );
add_filter( 'redirect_canonical', 'wpse_71666_trailingslash_cat_url', 20, 2 );

function wpse_71666_trailingslash_cat_url( $url, $request = '' )
    if ( 'category_link' === current_filter() )
        return rtrim( $url, '/' ) . '/';

    if ( "$url/" === $request and is_category() )
        return $request;

    return $url;
share|improve this answer
@tosho, Thanks. Can I ask you something, (perhaps I should start a new question). I have my permalinks like: /%category%/%postname%.html how can I remove the word uncategorized from the url's without removing the name of the other categories ? I think I will ask a new question. – user983248 Nov 7 '12 at 7:03
Since you are the man and just in case -> wordpress.stackexchange.com/questions/71805/… – user983248 Nov 7 '12 at 7:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.