I’m building a weekly leaderboard and trying to display posts from only the current calendar week Monday to Sunday using a date logged using the date picker field.
Currently, I’ve made it thus far, but can’t figure out how to only show posts from the current calendar week:
$args = array(
'meta_query' => array(
array(
'key' => 'date_of_ride',
)),
'post_type' => 'ride', 'posts_per_page' => 10, 'order' => 'DEC',
);
$leaders = new WP_Query( $args );
Any help appreciated,
Thanks
Solved it! Tackled it in a different way.
<?php
$args = array(
'date_query' => array(
array(
'after' => '-' . (intval(date('N')) - 1) . 'days',
'inclusive' => true
)
),
'post_type' => 'ride', 'posts_per_page' => 10, 'orderby' => 'meta_value_num', 'order' => 'desc',
);
$leaders = new WP_Query( $args );
?>