Home › Forums › Add-ons › Repeater Field › Filter by custom date
Hi There – i am trying to show all films that are shown on a certain day.
The date is a sub field (in row 1) of the screening info repeater field. It all works except when i try and compare the value of the screening date and the certain day (21/3/15). It doesn’t return any results (even though there should be) & says there are no films on. The return format of the date picker field is: 06/03/2015. I think there must be something wrong with the value, but I can’t figure it out! Any help much appreciated.
`
$the_film_query = new WP_Query(array(
‘post_type’ => ‘films’,
‘posts_per_page’ => -1,
‘meta_query’ => array(
array(
‘key’ => ‘screening_1_date’,
‘value’ => ’21/03/2015′,
‘compare’ => ‘=’
),
),
`
Hi just to get sure you try to find the correct row/field:
screening_1_date is the second row,
screening_0_date would be the first row
that means you try now to get date of second row of the repeater screening
Agh yes, that’s right. But it still doesn’t return any values 🙁
what is the value of screening_0_date?
if you dont filter/compare you should get it like that
<?php
$your_date = get_field('screening_0_date');
//variable like in array (if array has a <h1>titel</h1> it shows you the value as it is at "code-editor")
echo '<pre>';
echo htmlspecialchars(print_r($your_date,true));
echo '</pre>';
?>
i think it is because meta_value is 20150321
at your example.
that means try 'value' => '20150321',
You must be logged in to reply to this topic.
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!
Plugin boilerplates can do some of the heavy lifting during initial development. We look at four options to speed up your plugin creation. https://t.co/ZtMsdBxAHw
— Advanced Custom Fields (@wp_acf) June 5, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.