I have a custom post type (foobar), with two meta_fields:
updated_at
build_ran_at
I would like to make a single WP_query, that returns on the foobar-posts, where updated_at
is after build_ran_at
.
Both the fields are DateTime-fields.
Solution attempt
$foobar_query = new WP_Query([
'post_type' => 'foobar',
'post_status' => 'publish',
'posts_per_page' => 999,
'meta_query' => [
'relation' => 'AND',
[
'key' => 'updated_at',
'value' => ...?
'compary' => ...?
],
[
'key' => 'build_ran_at',
'value' => ...?
'compary' => ...?
],
]
]);
$returned_posts = [];
if( $foobar_query->have_posts() ):
while( $foobar_query->have_posts() ):
$foobar_query->the_post();
$returned_posts[] = get_post();
endwhile; // while( $foobar_query->have_posts() ):
wp_reset_query();
endif; // if( $foobar_query->have_posts() ):