Home Forums Add-ons Repeater Field Repeater field – row expiration with date and time picker


Repeater field – row expiration with date and time picker

  • Hello,

    I am using ACF PRO and I have created a few fields for a home page slider and I am trying to set an expiration date for each slide (each row of ACF) for more than a week already. I have tried to follow a few posts on the internet but nothing actually worked.

    I have created a field expiry_date at Custom Fields in the Back end using date time picker but I have no clue and succes on the codding to check if the date has passed = remove the row.

    Here is my current code on my home page:

    <?php if( have_rows('slider1')): ?>
    <div class="main-slider" id="main-slider">
      <div class="slider big-slider slider-wrap">
        <?php while ( have_rows('slider1') ): the_row();
    			$highlight2 = get_sub_field('highlight1');
    			$heading2 = get_sub_field('heading1');
    			$date2 = get_sub_field('dateandtime1');
    			$live2 = get_sub_field('live1');
    			$description2 = get_sub_field('description1');
    			$linktext2 = get_sub_field('linktext1');
    			$button2 = get_sub_field('button1');
    			$image2 = get_sub_field('sliderimage1');
        <div class="slide slick-bg" style="background-image:url(<?php echo $image2['url'];?>">
          <div class="container-fluid position-relative h-100">
            <div class="slider-content h-100">
              <div class="row align-items-center h-100">
                <div class="col-xl-6 col-lg-12 col-md-12">
                  <h3 data-animation-in="fadeInUp" data-delay-in="1"><span class="badge bg-warning text-dark"><?php echo $highlight2;?></span></h3>
                  <h1 data-animation-in="fadeInUp" data-delay-in="1"><?php echo $heading2;?></h1>
                  <div class="slide-info" data-animation-in="fadeInUp" data-delay-in="1">
                    <span><?php echo $date2;?></span> <span class="radius"><?php echo $live2;?></span>
                  <p data-animation-in="fadeInUp" data-delay-in="1"><?php echo $description2;?>
                  <div class="slider-buttons d-flex align-items-center" data-animation-in="fadeInUp" data-delay-in="1">
                    <?php if($button2):?>
                    <a class="btn hvr-sweep-to-right" href="<?php echo $button2;?>" tabindex="0"><i aria-hidden="true" class="fas fa-plus mr-2"></i><?php echo $linktext2;?></a>
                    <?php endif;?>
        <?php endwhile; ?>
    <?php endif; ?>
  • Hi @ivan9310
    If you dont mind, how did you fix this? Im in the exact same boat

  • Hello,

    In order to use the time picker you need to add few php functions at your page, after the block/slider is loaded. Declare and get today’s date, get start and end date of the picker and set an if statement to check whether or not todays date match between the pre-set interval in the back-end.

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

You must be logged in to reply to this topic.