javizoso Posted July 12, 2008 Share Posted July 12, 2008 Hi. I'm new at dealing with PHP, but I'm familiar with many of the operations used in it. I was trying to modify the wordpress LOOP to be based on a date hierarchy instead of post ID hierarchy. In other words, if there's a couple posts today, I'd like for it to print the date and then run a couple loops to format the types of content (tags) differently. Then check yesterday, etc, until it shows 5 days with posts. In other words, something similar to http://www.blogotheque.net. So far what i have is shown below, but it results in showing EVERY post in the 'tag' in ascending order X 5, and with the same date printout (july 12th), even though they are posted on different dates. I've been scratching my head over this for the past couple of days, so i would appreciate another point of view. Thanks. <?php get_header(); ?> <div id="content"> <?php $i=0; $j=0; while ($i<=4): $currentd = date("d", (mktime(0, 0, 0, date("m") , date("d")-$j, date("Y")))); $currentM = date("M", (mktime(0, 0, 0, date("m") , date("d")-$j, date("Y")))); $currentY = date("Y", (mktime(0, 0, 0, date("m") , date("d")-$j, date("Y")))); query_posts("year=$currentY&monthnum=$currentM&day=$currentd&order=DESC"); if (have_posts()) : ?> <div class="date"><span><strong><?php the_time('F j, Y'); ?></strong></span></div> <?php query_posts("year=$current_year&monthnum=$current_month&day=current_day&order=ASC&tag=interview"); if ( have_posts() ) : while ( have_posts() ) : the_post(); update_post_caches($posts); ?> <!-- formatting goes here --> <?php endwhile; query_posts("year=$current_year&monthnum=$current_month&day=current_day&order=ASC&tag=articles"); if ( have_posts() ) : while ( have_posts() ) : the_post(); update_post_caches($posts); ?> <!-- formatting goes here --> <?php endwhile; $i++; $j++; else: $j++; endif; wp_reset_query(); else: $j++ endif; endwhile; ?> <!-- Prev/Next page navigation --> <div class="page-nav"> <div class="nav-previous"><?php previous_posts_link('Previous Page') ?></div> <div class="nav-next"><?php next_posts_link('Next Page') ?></div> </div> </div> <?php get_sidebar(); ?> <?php get_footer(); ?> P.S. I also tried setting up the date with the code below, but it results in the same. I also tried echoing the value of the variables, and "i" increments normally, while "j" goes returns ( 1, 3, 6, 26, 31) for each run through the loop. Please help. $currentd = date('d',strtotime("-$j day")); $currentM = date('M',strtotime("-$j day")); $currentY = date('Y',strtotime("-$j day")); Link to comment https://forums.phpfreaks.com/topic/114437-help-with-dates-and-multiple-loops/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.