Retrieving post_date in nested loop (1 post)

  1. Quinn_
    Posted 8 years ago #

    I'm a WP Newbie, and as such have not had much experience with PHP and SQL (so go easy on me if it's an easy question).

    On single.php I would like to display a second post from a different category that was posted on the same day. Here's an example: The Original post was posted March 18, 2008. If a post from category "cake" was posted on March 18, 2008, display it:

    Here is what I have so far:

    <?php $dateOfOriginal = $post->post_date = date("Y m d",strtotime($post->post_date));
    query_posts('cat=' . $cake); while(have_posts()) : the_post();
      if ( $posts ) : foreach ( $posts as $post ) : start_wp();
        $dateOfPostInCake = $post->post_date = date("Y m d",strtotime($post->post_date)); 
        if($dateOfPostInCake == $dateOfOriginal) {
        } else {
      endforeach; else:
    endwhile; ?>

    The first post_date query works fine, but the second one does not (it defaults back to "1969 12 31"). I'm assuming it has something to do with being inside of a nested loop. Any ideas on how to make it work? Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic