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:
Its not the best solution but you can just do the filter after your query and check if the current date string is inside the post date modified,
e.g.
Based on this query to select all posts either published or modified today, you could just write this WP_Query to retrieve only the modified ones: