Home Forums ACF PRO Split loop per month based on date-picker


Split loop per month based on date-picker

  • Hi,

    I currently have a list of events on my website. Each of the events has a date (AFC Date Picker which is the_field(‘concert-datum’)).

    I was wondering if it is possible to loop through all events, but have them divided by month. (Each month has a new <h2>Name of the month</h2> before the list of the next events starts)?

    I currently have this query, that displays all events, ordered by their expiration date (which is the same as the ACF Date Picker Field):

    <div id="concert-list" class="container">
    	$args = array(	'numberposts'    	=>  -1,
    				  	'cat'				=>	'-1',
    				  	'order'             =>  'ASC',
    				  	'orderby'           =>  'meta_value', 
    				  	'meta_key' 			=>	'_expiration-date',
    	$query = new WP_Query( $args );
    		if ( $query->have_posts() ) {
    			while ( $query->have_posts() ) {
    					get_template_part( 'concert-single' );
  • Did you get anywhere with this?

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

The topic ‘Split loop per month based on date-picker’ is closed to new replies.