I'm having a problem with some PHP code in WordPress and I think the solution has to do with loops. I've had a look at http://codex.wordpress.org/The_Loop and http://codex.wordpress.org/The_Loop_in_Action but it's way over my head and I've already wasted my entire Saturday on this.
So the thing is I have a widget on my website's homepage. It displays the titles to the next 5 events happening and links to them. What I wanted to do was to also display the date when the events (they are like blog posts) were last modified.
The problem is that my code keeps returning the wrong date. I modified my post today, the 13th of December and it keeps outputting the 11th of December. I don't know where it's getting that date from. I've tried using both the_modified_date() and get_the_modified_date() with the same results. I'm guessing the function doesn't know which post to pull the date from and it has something to do with loops.
So I've been messing with the widget's code. Here's a simplified version of what I have:
foreach ($events as $event) {
if ( $event['event_date'] >= $site_date ) {
$lastMod = get_the_modified_date($phpformatstring);
echo $lastMod;
echo '<br><a href="' . get_permalink($event['ID']) . '" >' . get_the_title($event['ID']) . '</a>';
if ( !empty( $widget_display_count ) ) {
$counter++;
if ( $counter == $widget_display_count )
break;
}
}
}
I really hope someone can help me. If you want to try it with the widget I'm using, it's one called Events Listing Widget