[wp-hackers] is it a good idea to remove the category base?

Mike Schinkel mikeschinkel at newclarity.net
Sat Dec 3 10:34:13 UTC 2011


On Dec 3, 2011, at 12:53 AM, IC IC wrote:
> I'm sorry for not making my question clear, though I do appreciate all
> answers as far as the SEO aspect is concerned.
> 
> I was more on the performance side.
> 
> After reading Otto's article (
> http://ottopress.com/2010/category-in-permalinks-considered-harmful/,
> ), I thought removing the categories will have some impact. Please
> answer this question for a site that has about 200 cats and 100 pages
> or so.
> 
> When the cat base is missing, how would WP will interpret the order?
> Is that a page? or a cat? Isn't more work to do? Or was it going to
> check all the cats anyway so it would not matter anyway...

Otto was writing about a circumstance that is very specific to the rewrite rules architecture that is  WordPress' built-in method for URL routing.  However it is easy to "front end" the rewrite system using a simple hook and avoid the issues in the rewrite system that arise related to category archive URLs.

Ironically I just the other day wrote the following plugin for a friend to allow category archive URLs without a '/category' prefix. It is very lightweight though it could be optimized a bit more if it really mattered. As you can see it is quite simple:

https://gist.github.com/1421235

The plugin simply checks to see if the first URL path segment is a category slug; if it is then the plugin tells WordPress to load the category archive but if not it lets WordPress handle the URL routing. It works even if there is a page with the same URL; it basically "masks" that page's URL. 

I could update the plugin to give a warning when a page is created with the same name as a category or a category the same name as a page, but it was just a quick project as a favor for a friend, so it is what it is!  Perfection is 3x more effort than "good enough," or so said my college computer science professor. 

(Otto probably won't like this plugin. But then Otto never likes it when people modify URL routing,  though I've never quite figured out why that's one of his hot buttons... :)

> IN the ASP world, request.queryString, request.cookies, request.post
> etc.... are the recommended way of getting the user input. but asp
> allows me to go request("firstname"). 

I came from the ASP world, long ago.  What you are looking for to match the ASP funciton are the PHP superglobal variables, especially $_REQUEST, $_GET, $_POST and $_SERVER:

http://php.net/manual/en/language.variables.superglobals.php

Hope this helps.

-Mike




More information about the wp-hackers mailing list