I'm trying to create a query in WordPress that displays only the posts that were edited today, excluding those posted today. I've tried several variations but nothings seem to be working:
$today = current_time('Ymd');
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => '10',
'meta_query' => array(
array(
'key' => 'modified',
'compare' => '>=',
'value' => $today,
'type' => 'NUMERIC,'
)
),
'orderby' => 'modified',
'order' => 'DESC',
'ignore_sticky_posts' => '1'
);
I'm not quite sure what to put in key
, although that isn't the only problem.
If I get it right, with "displays only the posts that were edited today, excluding those posted today."
I guess you mean display ONLY old published posts modified/edited today.
If that is the case, this might help you:
<?php
// query args
$args = array(
'posts_per_page' => '10',
'post_type' => 'post',
'post_status' => 'publish',
'orderby' => 'modified',
'order' => 'DESC',
'ignore_sticky_posts' => '1',
'caller_get_posts' => 1
);
// query
$updated = new WP_Query($args);
// loop
while($updated->have_posts()) : $updated->the_post();
$today = current_time('Y-m-d'); // current date a.k.a. TODAY
$pub = get_the_time('Y-m-d', $updated->ID); // date when post was published
$mod = get_the_modified_time('Y-m-d', $updated->ID); // date when post was last modified
// if post NOT published today AND was modified today display:
if ( $pub !== $today && $mod === $today ) :
?>
<!-- here goes your normal wp game -->
<h1><?php the_title ?></h1>
<span><?php the_date(); ?></span>
<p><?php the_excerpt(); ?></p>
<?php endif; endwhile; ?>