Support

Account

Home Forums Add-ons Repeater Field Filter by custom date

Solved

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>'; 
    ?>
  • It’s printing the date values like this:
    21/03/2015

  • would it work if you use LIKE instead of = at compare?

  • i think it is because meta_value is 20150321 at your example.
    that means try 'value' => '20150321',

  • Yeah that worked! Thanks a million πŸ™‚

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.