Forum Moderators: open
Look on the permalink settings page. That's where you change it.
If you're looking to use that second option for inbound links or something, you could always use rewrites.
you can also do a .htaccess rewrite but know what you are doing and test it carefully.
Things may break depending on how you structure your urls e.g. Calendar function may require dates
Like Ergophobe, I dont see why you would have /category/category-name/ as it seems redundant. Perhaps you want /category/postname/ ?
example.com/category/widgets
example.com/category/whozits
So it's not so much the redundancy there, but the namespace collision of you have a page (or depending on your permalink structure even a post) at
example.com/widgets
and then you go and tag something "widgets". Of course you can avoid that by always adding something numeric, but it just seems that forcing that structure on WP seems like a bad idea. You could reduce the "categories root" to a single letter (example.com/c/widgets) but I would hesitate to get rid of it entirely.
Add the following codes in your functions.php
function custom_rewrite_rules($rules) {// The default rewrite rules are stored inside $rules which is part of the $wp_rewrite object.
// The array keys are the pattern terms and the values are the substitution terms.
$custom_rules = array();
$custom_rules['(.+?)/feed/(feed¦rdf¦rss¦rss2¦atom)/?$'] = 'index.php?category_name=$matches&feed=$matches[2]';
$custom_rules['(.+?)/(feed¦rdf¦rss¦rss2¦atom)/?$'] = 'index.php?category_name=$matches[1]&feed=$matches[2]';
$custom_rules['(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?category_name=$matches[1]&paged=$matches[2]';
$custom_rules['(.+?)/?$'] = 'index.php?category_name=$matches[1]';// You might want to remove the default rules otherwise the original default permalink URLs still works.
unset($rules['category/(.+?)/feed/(feed¦rdf¦rss¦rss2¦atom)/?$']);
unset($rules['category/(.+?)/(feed¦rdf¦rss¦rss2¦atom)/?$']);
unset($rules['category/(.+?)/page/?([0-9]{1,})/?$']);
unset($rules['category/(.+?)/?$']);return $custom_rules + $rules;
}
add_filter('rewrite_rules_array','custom_rewrite_rules');
Note:
If you apply new rewrite rules using the rewrite_rules_array filter you need to refresh the rewrite rules that Wordpress has stored in a hidden option by resaving the Permalink Structure in the admin panel.
[1][edited by: Murasaki at 6:54 pm (utc) on Feb. 12, 2009]