Categories, Pages, and URLs

Tuesday, August 8, 2006

A brief update from the Information Architecture Implementation Subcommittee…

So we’ve got URLs like this (pages):
http://staging.false-profit.com/partners

And URLs like this (categories):
http://staging.false-profit.com/category/events

That’s annoying, because I really want the second URL to just be http://staging.false-profit.com/events/ — it shouldn’t matter that it’s a category. There’s a thread on the WP forum about this:
http://wordpress.org/support/topic/41363

But no one there seems to have made much progress. Setting the category-base to ./ doesn’t work. I see our two options as this:

1. Use a PHP eval plugin like RunPHP to execute loop code within pages set up at each URL we care about. Use the get_posts template tag.

Pros: Not much code to write. Makes the page for a given URL easy to find and update. Each page can be totally customized as far as how it displays things.

Cons: Need to put what’s basically the same loop code into many pages. (Could package it up as a function and include it to avoid some of that weirdness.) Results in two places to find the same stuff: /news and /categories/news would both list news posts, maybe in different ways, which is weird. There might be extra overhead for the RunPHP plugin.

2. Use mod_rewrite or a custom 404 to proxy queries for anything not found in the root to /category/that_thing. Use sticky category posts or custom category templates to provide the static content in each page.

Pros: Don’t need to create a page for each category in addition to the category itself. No plugins or code. Only need this one rewrite rule.

Cons: To customize the category appearance, you have to create a custom category page within the theme. If someone requests a page that doesn’t exist and doesn’t have a category, we’ll end up looking in /nonexistent and /category/nonexistent, which is weird if they’re asking for nonext.jpg or something like that. It doubles the overhead of each 404.

I lean toward the former. (Makes customizing the appearance of what’s going on at each URL simpler and keeps people from needing to muck around in the theme with stuff like category-8.php which is annoying to try to figure out what it goes with.) Thoughts? Other ways to handle this?

Update: Third option to hack the classes.php. I still prefer the first method.

Postscript: What we’ve actually done is two things:

Use a redirect plugin to forward the URLs we want to the URLs that exist. This makes it easy for any of our editors to create a new top-level URL by just creating a page and setting a Custom Field on that page called “redirect” — no mod_rewrite hacking necessary.

Write some PHP to put The Loop on pages (as the original option 1 suggested). Examples at the Dividend and Equity pages.