Support

Account

Home Forums Front-end Issues Show coming 6 birthdays

Helping

Show coming 6 birthdays

    • rd88

    • March 13, 2019 at 1:39 am

    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>";
    ?>
  • Check this page out:
    https://support.advancedcustomfields.com/forums/topic/only-show-posts-if-the-date-picker-date-is-still-in-the-future-or-today/

    You can use that and then just restrict it to 6 instead of 4.

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.