Support

Account

Home Forums Add-ons Repeater Field future dates table in single.php Reply To: future dates table in single.php

  • Dear John,

    thank you for your reply.
    Do you mean it like this? There must be a mistake somewhere…
    maybe with the { ?
    Sorry I´m an absolute newbie in php…

    <?php
    
    while ( have_rows('t_block') ) : the_row(); 
        $now = strtotime(date('Y-m-d', time()));
        // I am assuming that your date is stored as 'Y-m-d'
        // see strtotime php doc form more information
        $end_time - strtotime(get_sub_field('ende'));
        if ($now > $end_time) {
        // not in the future, go to the next row
            continue;
        }
    
    // check if the repeater field has rows of data
    if( have_rows('t_block') ):
    
    echo '<h2>' . 'Reisetermine' . '</h2>';
    echo "<table>";
    echo '<tr> <th>'.''.'</th>';
    echo '<th>' . '' . '</th>';
    echo '<th>' . Anreise . '</th>';
    echo '<th>'.''.'</th>';
    echo '<th>' . Abreise . '</th>';
    echo '<th>' . 'Preis p.P. <br> im DZ' . '</th>';
    echo '<th>' . '' . '</th>';
    echo '<th>' . '' . '</th>';
    echo '<th>' . '' . '</th>';
    echo '<th>' . '' . '</th>';
    echo '<th>' . '' . '</th></tr>';
    
     	// loop through the rows of data
        while ( have_rows('t_block') ) : the_row();              
    		
    
    $date_beginn = DateTime::createFromFormat('Ymd', get_sub_field('beginn'));
    $date_ende= DateTime::createFromFormat('Ymd', get_sub_field('ende'));
    $preis= get_sub_field('preis');  
    $preis_ez= get_sub_field('ez_preis');
    $buchbar= get_sub_field('buchbar'); 
    $sprache= get_sub_field('sprache');   
    $anfrage= get_sub_field('anfrage');   
    $bemerkung= get_sub_field('bemerkung');   
    $garantiert= get_sub_field('gesichert');  
    
            // display a sub field value
    
          echo '<tr><td>' . $garantiert . '</td>';
    	  echo '<td>' . $buchbar . '</td>';
          echo '<td>' . $date_beginn->format('d.m.Y') . '</td>'; 		
              echo '<td>' . '-' . '</td>';
        echo '<td>' . $date_ende->format('d.m.Y') . '</td>';       
        echo '<td><strong>' . $preis . '  € </strong> </td>';
        echo '<td>' . $preis_ez . ' </td>';
        echo '<td>' . $sprache . '</td>';
        echo '<td><strong>' . $anfrage . '</strong></td>';
       	echo '<td>' . $bemerkung . '</td> </tr>';
        endwhile;
    
    echo "</table>";
    
    else :
    
    echo get_post_meta($post->ID, 'traveldates' ,true); 
    
    endif;
    
    ?>