2
When I create a Wordpress post, I determine an expiration date through a plugin called Post Expirator. My question is how can I delete these posts from the home page, categories and the like when they expire.
Also, I would like to have all expired posts displayed at a certain point on my site.
I’ve been trying to use 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 posts that add an expiration date, regardless of the date on which it expires, now I want to know how I can delete them in a loop comparing the date of their expiration with the current date.
Sincere doubt, the plugin is called Post Expirator and does not expire the post when doing a query? Some way it has to do the correct query that does not show such expired posts, no?!
– brasofilo
The option it provides after it expires is to delete the post, turn it into a draft, or move to some category. What I want is to keep the posts in the category where they were created, but at the bottom of the page, separate from posts that have not expired or have no expiration date.
– Rafael
Okay. It’s just that this post turning into a draft or changing category is not written in the question (it’s cool to add, and it’s just [Edit]). I don’t know how to solve that kind of problem search query as a starting point to find the solution: http://wordpress.stackexchange.com/search?tab=votes&q=%5bwp-query%5d%20meta_key%20date%20is%3aa
– brasofilo