Here’s my problem: I’m creating an issue-based magazine template. 3-5 times a year a set of 10-15 posts will be published under a particular issue theme with an editorial as a forward for it all. When I’m viewing an archived post from a particular issue I would like to have it’s issue-theme displayed before the post.
Here’s my solution: My home page is a static page with dynamic elements (I want to reserve index.php for a blog about the magazine). It has these three loops:
<div id="issue-theme"> <h3>Issue Theme</h3> <!-- begin latest issue theme --> <?php query_posts('showposts=1&cat=4'); ?> <!-- cat-4 is my "theme" category --> <?php while (have_posts()) : the_post(); ?> <!-- do stuff --> <?php endwhile; ?><!-- end latest issue theme --> </div> <div id="editorial"> <h3>Editorial</h3> <!-- begin latest editorial --> <?php query_posts('showposts=1&cat=3'); ?> <!-- cat-3 is my "editorial" category --> <?php while (have_posts()) : the_post(); ?> <!-- do stuff --> <?php endwhile; ?><!-- end latest editorial --> </div><!-- #editorial --> <div id="issue-index"> <h3>In this issue</h3> <!-- begin index of issue --> <?php query_posts('showposts=-1&<?php index_control_date ?>&cat=-3,-4'); ?> <?php while (have_posts()) : the_post(); ?> <?php endwhile; ?><!-- end index of issue --> </div><!-- #issue-index -->
Note the “index_control_date” function in the last loop’s query_posts. I’d like to generate this with a plugin that pulls the published date out of the first cat-4 (my “theme” category) post on the page. Then my third loop, the issue-index, will only display posts related to the current issue—or posts published the same day as the theme post.
For an archive page I could have custom category template that lists all the theme posts. Each theme posts links to a page that mirrors the functionality of my custom home page template.
I’d also need the plugin to get the published date of posts not in the theme category on single pages. I could then use that value to run a loop that shows the theme associated with that particular post.
Does that make sense?
Here’s my real problem: I don’t know how to write this plugin. Can a plugin even do this with query_posts. Is there an easier way to do an issue-based magazine site with WordPress? Any help?
- The topic ‘Dynamic Date in query_posts’ is closed to new replies.