Support

Account

Home Forums Front-end Issues Show coming 6 birthdays

Helping

Show coming 6 birthdays

  • Hello everyone,

    I’ve been looking for a solution for a while. We now have a list with employee name and birthdate. We would like to have a sorting of the coming 6 birthdays. date of birth field is a datepicker.

    This is our code:

    <?php
    
    echo '<table style="width:100%; text-align:left;">';
      echo "<tr>";
        echo "<th>Name</th>";
        echo "<th>Verjaardag</th>";
      echo "</tr>";
    
    $loop = new WP_Query( array( 'post_type' => 'medewerkers', 'posts_per_page' => 10 ) ); 
      while ( $loop->have_posts() ) : $loop->the_post(); 
    	if ( have_rows( 'persoonsgegevens' ) ) : 
    		while ( have_rows( 'persoonsgegevens' ) ) : the_row();
    			echo "<tr>";
    			    echo "<td>", the_title( '' ), "</td>";
    			    echo "<td>", the_sub_field('geboortedatum'), "</td>";
    		 	echo "</tr>";
       		endwhile;
    	endif;
    endwhile;
    echo "</table>";
    ?>
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Show coming 6 birthdays’ is closed to new replies.