Wordpress cool feature of the day: Category Pages
- Filed under: Wordpress News
- Date: Sep 3,2006
I was building a theme for a client the other day (yes, I have to get around to actually building one of my own for this site) and I was at a loss for how he wanted his website layout to flow: he wanted separate pages for each category he had in his blog so he could go into more detail. Donning my programmer cap, I figured it would take some serious coding to get this feature implemented, but a quick trip to the codex proved me wrong. The smart fellows over there anticipated this and developed a system to deal with blogs that have specific category customization needs, or those with no needs at all, who don’t want extra stuff cluttering their theme.
Category presentation in Wordpress is modeled from specific to general, that is, when presenting content for a specific category, Wordpress is going to first look for a category page that contains the ID of the category in question. For example, let’s assume we had a category for trees that had an ID of six. When presenting the content, Wordpress looks in your theme directory for a page named category-6.php . If it does not find a page like that, it degrades to the next most specific page for categories: category.php . Let’s assume again that we never got around to creating THAT page, the system then degrades and looks for: archive.php. But, we were really lazy, and never made an archive page. Well the system is smart enough to compensate for that, and degrades all the way back to index.php.
Check out the codex for a complete overview of category pages and their implementation in Wordpress.

Leave a comment
You must be logged in to post a comment.