Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Under "Settings > Permalinks", we can set up the default category base name to use for our category landing pages. For example, site.com/categories/my-first-category/.

Is there a setting I can add to my functions.php to allow the option to remove the category base and direct link to the category? For example, the above link becomes: site.com/my-first-category/

I realize that this opens up the possibility of having conflicting post names and category names (assuming I have a post slug that's the same as a category slug for example), but in this case, my post permalinks end in .html and my category permalinks will not, so there should never be a conflict (I expect).

share|improve this question
    
add comment

1 Answer

up vote 1 down vote accepted

there is an answer to on how to do that in the WordPress way here

but a faster way is using the .htaccess file by adding this line

RewriteRule ^category/(.+)$ http://www.yourblog.com/$1 [R=301,L]

just make sure you change http://www.yourblog.com/ to what ever is needed.

Hope this helps.

share|improve this answer
    
@בניית אתרים - Thanks! Its a shipping WP theme so I won't have direct access to htaccess for adding the filter. Can this be done from functions.php perhaps? How easy is it to undo? –  Scott B Jan 25 '11 at 16:57
    
@בניית אתרים: That does a redirect from the old style to the new style, but how does WordPress know that the new URLs are of this form? I think you need to add something to the WordPress rewrite rules too, otherwise it won't know what to do with incoming URLs of this form –  Jan Fabry Jan 25 '11 at 17:04
    
@Scott B - i think you are looking for somtheing like this wordpress.stackexchange.com/questions/6104/… –  Bainternet Jan 25 '11 at 17:11
    
@Scott B - also look at wordpress.org/extend/plugins/wp-no-category-base a plugin that does it for you. –  Bainternet Jan 25 '11 at 17:18
add comment

Your Answer

 
discard

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.