Best way to do complex category pages?
-
I’m building a WP 2.0.4 blog in which some of the category pages need to have very different page logic from others. I need some advice on the best way to implement this.
As an example, one of my category pages needs to have some intro text, show the latest post in the category, show excerpts of recent posts in that category, and show a listing of posts in a subcategory.
Another page needs to show intro text, and all the posts by a specific author.
Another page needs to show intro text, a list of subcategories and a single post from one of the sub-cats.
I really don’t like the Template Hierarchy’s approach to category-specific templates, since it relies on category ID — I’d much prefer to refer to cats by name, so I can avoid problems if the IDs change (DB migration, category reorganization, etc.)
I’m considering bypassing WP’s automatic category URL resolution altogether, and using WP Pages and their templates to do this:
For each category page I need, I’d create a Page. On each display Page, the intro text and page title would come from the Page info — allowing editors to easily change that boilerplate text without diving into the PHP template. The Page would have its own custom template, where I use query_posts() in the category to pull the info I need.
If I want the pages grouped (e.g. to make the URLs hierarchical instead of flat), I’d make a parent Page, not really meant to be displayed, but to group subpages. To avoid readers getting caught in WP’s auto-category-URL resolution, I could have ‘category.php’ simply redirect to the Page for the category they’re looking for.
Does this sound like a viable approach, or am I asking for trouble? Thanks!
- The topic ‘Best way to do complex category pages?’ is closed to new replies.