Sorry for a probably dim question but I can’t find the correct terminology to find the solution.
I’ve got a wordpress loop [a php while loop] for my post_type event. Each post has a value with a date string. I am comparing this string with the current date. The date values start in the future and end a few years ago.
When the loop gets to posts with date values lower than the current date [$date > $eventdate
] I want to insert some code [a divider <article>
] and then continue my loop. How do I do this?
Seems very simple but please help as I’m stuck!
EDIT: I tried to nest two conditional while loops with the divider code in between but that was very bad. Then tried something similar with if’s but I got that wrong too. Here’s the [simplified] code to work with:
<?php
$date = date(Ymj);
if ( have_posts() ) : while ( have_posts() ) : the_post();
$eventdate = get_post_meta($post->ID, 'event-date', true); ?>
<article>post goes here</article>
<?php endwhile; else:
?>
2 comments