WP_Query by MAX post_id?

try this <?php $new=new WP_Query(array(‘posts_per_page’=> 1,’order_by’=>’DESC’)); $max_id; if($new->have_posts()){ while($new->have_posts()) { $new->the_post(); $max_id=the_id(); } } echo $max_id;

Need to show 7 posts from actual date

Try this static function loop_args($parent_id, $number) { $today = getdate(); $args = [ ‘cat’ => $parent_id, ‘showposts’ => ‘7’, ‘orderby’ => ‘ID’, ‘order’ => ‘asc’, ‘date_query’ => array( array( ‘year’ => $today[“year”], ‘month’ => $today[“mon”], ‘day’ => $today[“mday”], ), ), ]; return $args; }

Custom WordPress post query for displaying time-released content on website

Use a meta query. Since ACF stores dates as Ymd you can just treat the value as a number: $date_query = array( ‘key’ => ‘start_date’, // ACF date field name ‘type’ => ‘NUMERIC’, ‘value’ => ‘20200101’, ‘compare’ => ‘<=’, // All posts with start date before/on January 1st 2020 ); $args[‘meta_query’] = array( $date_query ); … Read more