Archive – Show Page Month Headers

I changed my approach in the end. I just called a single query and added the logic to check the date of the last post was in a different month: $today = date(“r”); $articledate = get_the_time(‘r’); $difference = round((strtotime($today) – strtotime($articledate))/(24*60*60),0); if ($month_sort == true && ($difference <= 7) && $current_week == null) { $vpost_count … Read more

date_query won’t accept day parameter, but will accept month and year for a custom post

As said in comments, you should use meta_query. For help on how to query posts by ACF meta field, you can check the ACF documentation: https://www.advancedcustomfields.com/resources/query-posts-custom-fields/ $args = array( ‘numberposts’ => -1, ‘post_type’ => ‘event’, ‘meta_key’ => ‘location’, ‘meta_value’ => ‘Melbourne’ ); // query $the_query = new WP_Query( $args );

Get posts only from current calendar week

I think I know what happens here… Most probably that Monday is another week – last one in 2018, and it makes sense. Last day of 2018 can’t be the first week of 2019 😉 So I would query it in a different way: ‘date_query’ => array( ‘after’ => ‘-‘ . (intval(date(‘N’)) – 1) . … Read more

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; }

date_query is showing duplicate results

As I said in comments, you can do this in one query by making use of the relative time and date functionality in PHP which is also vailable in a date_query. You simply need to pass something like 2 days ago to the after parameter in the date_query to get posts from today, yesterday and … Read more