Support

Account

Home Forums Add-ons Repeater Field How to show only fields if the date is true

Unread

How to show only fields if the date is true

  • Hello,

    I’m looking since couple of hours and I dont found and to be honest, i don’t have enough skills to get everything.

    My problem is, i made a repeater with some text information and 2 date pickers. 1 for start and the 2 for end.

    I want to display only the repeater which is matching with TODAY. Refering with the start, end and between date only. Not the past or the future. From now, I dont have the past fields, but still the future.

    May someone help me ?

    Cheers
    David

    Here is my code:

    <?php
    // check if the repeater field has rows of data
    if( have_rows('mets') ):
    
    // loop through the rows of data
    while ( have_rows('mets') ) : the_row();
    
    // display a sub field value
    ?>
    
    <?php
    
    $datedeb = get_sub_field('begin', false, false);
    $datefin = get_sub_field('end', false, false);
    $today = strtotime(date('Ymd'));
    $promoend = strtotime($datefin);
    $datedeb = new DateTime($datedeb);
    $datefin = new DateTime($datefin);
    
    ?>
    
    <?php if ($promoend >=$today): ?>
    
    <?php
    
    the_sub_field('nom_du_mets');
    											?>
    
    <?php endif; ?>
    
    <?php
    
    endwhile;
    
    else :
    
    // no rows found
    
    endif;
    
    ?>
Viewing 1 post (of 1 total)

The topic ‘How to show only fields if the date is true’ is closed to new replies.