Support » Requests and Feedback » Category Base (and the removal of)

  • Are there any imminent plans to address this issue? I understand that it’s a neccessity with the current re-writing engine/structure, but I believe it does need to be addressed.

    “Pretty URLs” are supposed to be functional (i.e. hackable – in mimicking a folder structure, one should be able to remove a level to navigate to its parent) as well as readable (by both search engines and visitors). Currently, category-based permalinks are neither hackable nor logical.

    I vote for the removal of the category base, and new rules prohibiting the ability to assign posts, pages and categories duplicate names (or at least slugs). Many people are using WordPress as a CMS these days and in my eyes this is one of the few obstacles presented.

    I know there is a plugin, but it’s a hack that’s buggy at best and even worse with 2.2.

    I love WP and appreciate the massive amount of hard work you guys put in, I just think it would be a shame to lose potential users over this.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Anything in trac requesting this already?

    Have you checked the ideas area as well?

    Are you saying that because you know that there is, or because you’re assuming I haven’t checked?

    I used the Support forums search tool to see if there was any mention but couldn’t find anything bar a few threads discussing it in troubleshooting. I’ve not seen Trac before, thanks for the link. But even if it has been mentioned previously, this is the Requests and Feedback forum so duplicate posts should not be an issue, it only adds weight to the issue. I’m not asking for replies.

    Found this, thank you! 🙂

    Are you saying that because you know that there is, or because you’re assuming I haven’t checked?

    Neither! Just trying to suggest resources.

    You may feel posting here adds weight, but truthfully, we don’t really see all that many developers wander through any of the support forums.

    Glad to see you found one over in extend – don’t forget to click the stars to vote it up!

    I agree it would look nicer without having to have a Category Base in category URLs. There has been some discussion about a plugin by someone at but that plugin has not been released and work on it was stopped, also a htaccess work-around to fix the paging problem while browsing category archives using the plugin at

    One solution I am looking for would be a way mybe through htaccess to tell WordPress to point to following:
    instead of

    Cause the only problem is that when it point to then WordPress doesn’t know it is on page 2, it thinks it is still on page 1 of the archive so it doesn’t let the user navigate to page 3 when clicking “Previous Entries”.

    I came up with a hack that fixes the multi-page problem. (You can see how it working here:

    1) Use a hack from bloggerholic, that removes the base category from links. You have to edit category-template.php like so:

    function get_category_link($category_id) {
    	global $wp_rewrite;
    	$catlink = $wp_rewrite->get_category_permastruct();
    	///////// ADD THIS LINE
    	if (!(isset($_GET['paged']) && !empty($_GET['paged']))) $catlink = str_replace('/category', '', $catlink);

    2) And then to fix multi-page links that are broken by the previous hack, I just modify the “next page” link to put the category base back in, which paged archives require to function. Make the following change to link-template.php :

    function next_posts($max_page = 0) {
    	$the_unmodified_link = clean_url(get_next_posts_page_link($max_page));
    	if (preg_match('/archive/', $the_unmodified_link)) echo $the_unmodified_link;
    	else echo preg_replace('/web/' ,'web/archive', $the_unmodified_link);
    	// echo clean_url(get_next_posts_page_link($max_page));

    And that’s it! I actually used the category base “archive/” instead category, cause it makes more sense for the second and third pages to be under archives, and the rest not. (And wordpress is located in the “web” directory to keep it separate from the rest of the website as well). You can see how it works here:

    I don’t think it messes up anything else, but you might want to test it yourself as well.

    You are a legend, I will try this out when I get home. If this works, I will be the happiest man alive.

    blaisefreeman, this seems to get us closer to our goal of being able to remove category base from our blogs. But it still doesn’t work for me it seems.

    You can see a demo here:

    I guess though I don’t understand what you mean by /web/ and /archive/ in that php code. Should one use /archive/ before the page/2/ in all links for this to work? Could you make it work without the need for that /archive/ category base for paged links?

    I wouldn’t mind that WordPress used this type of URL:


    instead of


    if that’s what needed for this to finally work.

    My directions were very poor. Let me try again:

    1) Under Options >> Permalinks, Set your Category Base to /category

    2) Use the following hack (modified from bloggerholic), that removes the base category from links (unless it’s a multi-page link). Find the function “get_category_link($category_id)” in category-template.php (in the wp-includes folder) and insert the following hack, like so…

    function get_category_link($category_id) {
    	global $wp_rewrite;
    	$catlink = $wp_rewrite->get_category_permastruct();
    	///////// ADD FOLLOWING LINE ///////
    	if (!(isset($_GET['paged']) && !empty($_GET['paged']))) $catlink = str_replace('/category', '', $catlink);

    3) Next, you have to fix the multi-page problem that results from the above hack. For some reason, multi-page permalinks require a Category Base. So we have to add the category base back in for the function that produces the link to page 2, next_posts(). Make the following change to the link_template.php (in the wp-includes folder):

    function next_posts($max_page = 0) {
    	//////// ADD THE FOLLOWING LINES ////////
    	$the_unmodified_link = clean_url(get_next_posts_page_link($max_page));
    	if (preg_match('/category/', $the_unmodified_link)) echo $the_unmodified_link;
    	else echo preg_replace('/yourdomain\.com/' ,'', $the_unmodified_link);
    	// echo clean_url(get_next_posts_page_link($max_page));


    1) replace, with your domain, but do not prefice with www, and also escape non-alphanumeric characters (such as . and /)
    2) You can see an example of this hack working on my site, but it has two excpetions: wordpress is installed in a subdirectory, and the Category Base was changed to archive/, so the exact code I used is a little different, so the resulting links are for page 1 and

    Hope that was more clear Charbax.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Category Base (and the removal of)’ is closed to new replies.