When I create a post in Wordpress, I determine an expiration date through a plugin called PostExpirator. My question is how do I delete these posts from the home page, categories, and the like when they expire.
In addition, I would like to make all expired posts appear at a certain point on my site.
I've tried using meta_keys and meta_value, but I'm not succeeding.
<?php $args = array(
'meta_key' => '_expiration-date',
);
$query = new WP_Query( $args ); ?>
<?php if($query->have_posts()) : ?>
<?php while($query->have_posts()) : $query->the_post() ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile ?>
<?php endif ?>
With the above code I can display the posts that I add an expiration date, regardless of the date it expires, I now want to know how I can delete them in a loop by comparing their expiration date with the current date.