Home › Forums › General Issues › Display post in date field select › Reply To: Display post in date field select
Hi @serviceweb
Yes, you can do it. First, you need to get the current day by using the date()
function. After that, you need to query the posts based on the current day. It should be something like this:
$today = date('Ymd');
$the_posts = get_posts(array(
'numberposts' => -1,
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'date_picker_field_name',
'value' => $today,
),
),
));
print_r($the_posts);
Don’t forget to change the “date_picker_field_name” text with your date picker field name. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/query-posts-custom-fields/.
Also, please keep in mind that there are differences between date picker field in PRO and free version. To learn more about it, kindly check this page: https://www.advancedcustomfields.com/resources/date-picker/.
I hope this helps 🙂
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.