I need to display "Featured posts" randomly for each day of the week on a single page. Posts need to be current.
What I want to do: I load 7 posts in a variable using WP_Query, test each post to see if it's current, and display only the remaining ones.
Problem: I can't find how to delete an entry in a while loop.
Init of the page:
$args = array(
'post_type' => 'listing',
'post_status' => 'publish',
'post__not_in' => array($post->ID),
'orderby' => 'date',
'order' => 'DESC',
'meta_key' => 'featured_calendar',
'meta_value' => 'on',
'posts_per_page' => 7
);
$featured = new WP_Query($args);
if ($featured->have_posts()) : while ($featured->have_posts()) : $featured->the_post();
$theending = get_post_meta($post->ID, 'theend', true);
if ($theending > time()){
echo "All Good";
} else{
//Delete the entry
}
endwhile;
endif;
Inside the days of the week loop:
if ($featured->have_posts()) : while ($featured->have_posts()) : $featured->the_post();
//Display of remaining posts
endwhile;
endif;