The first problem you have is that you can’t use “Date” as the meta type because ACF date fields are not stored as “dates” in the database. the type needs to be strings or numbers.
date('Ymt') will return the last day of the month for a given date.
<?php $today = date('Ymd'); $last_of_month = date('Ymt', strtotime(date('Y-m-d'))); $args = array( 'posts_per_page' => 7, 'post_type' => 'competicions', 'orderby' => 'meta_value', 'order' => 'asc', 'meta_key' => 'datahora_prova', //ACF date field 'meta_query' => array( array( 'key' => 'datahora_prova', 'value' => $today, 'compare' => '>=', ), array( 'key' => 'datahora_prova', 'value' => $last_of_month, 'compare' => '<=', ) ) );
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
© 2023 Advanced Custom Fields.