How can I link to the first post of each category in a dynamically created category list in wordpress?
October 21, 2008 6:18 PM
Subscribe
In a Wordpress-powered site, how can I create a list of categories that link to the first post in that category rather than the category archive?
I'm using wordpress as a cms for a portfolio site and I'd like to create a dynamic list of categories with each category as a link to the first post in that category.
I currently use wp_list_cats(); to list the categories I want, but each link goes to the category archive page. I've temporarily gotten the behavior I want by limiting the category template to display only 1 post per page. If posts move around or get changed, however, the permalinks change for particular content that may be bookmarked or linked to elsewhere (i.e., what was at blah.com/?cat=26&paged=2 is now at blah.com/?cat=26&paged=5)
I'm not scared of code, just running into some difficulty determining exactly how to implement what I want; it seems like I could take a list of the category ids in the site, call up the posts for each category, put the first post id from each category into an array associated with the category names, and then print out the list of category names using the first post id as a link.
Is there an easy way to do this? A hard way?
I'm using wordpress 2.5 and higher
posted by msbrauer to computers & internet (4 comments total)
1 user marked this as a favorite
posted by msbrauer at 6:21 PM on October 21, 2008