Support

Account

Home Forums General Issues Helping event posts displaying by month Reply To: Helping event posts displaying by month

  • Hi @ikazi

    You need to save the month in a temporary variable and then check if the current month is the same with the one in the temporary variable or not. Maybe something like this:

    <?php if( $the_query->have_posts() ): ?>
    <?php $current_month = ""; ?>
    <ul>
    <?php while( $the_query->have_posts() ) : $the_query->the_post(); ?>
    <li class="list-representations">
    //month display tag
    	<div class="list-separator-month">
    		<h2>
    		<?php
    			$dateformatstring = "F Y";
    			$unixtimestamp = strtotime(get_field('date_start'));
    			$pretty_month = date_i18n($dateformatstring, $unixtimestamp);
    			if ($current_month != $pretty_month){
    				echo $pretty_month;
    				$current_month = $pretty_month;
    			}
    			?>
    		</h2>
    	</div>
    	<article>

    Hope this helps.