Along with my plugin work I’ve been spending a bit of time on template experiments, proof of concepts in organizing content differently in WordPress 1.5.
A method that’s requested often, and one that caught my interest, is to display recent posts organized within their respective categories, instead of just by date (descending). I’ve come up with one solution through a (very) modified post loop in a home.php template, and would like feedback on what I have so far, such as improvements to structure, streamlining code, etc.
The modifications to The Loop I’ve made still only handle the last
Nposts, but it first retrieves the categories they’ve been posted to, and then organizes posts under each. By default categories are organized by latest post first, but uncomment the following line (remove the
//) to sort/list the categories alphabetically:
// uasort($cats, strcasecmp);
I’ve commented throughout the template, but please ask if something isn’t clear.
Finally, the template is designed around the default (Kubrick) theme, so it’ll work best with that; however the loop framework can be imported into any layout (with appropriate tweaking).
- The topic ‘Display by Category home.php template’ is closed to new replies.