Troubles Creating a Double Loop in Own Template
-
I’m trying to create a double query and a double loop in a website using the plugin event organiser in order to separate current events and future events. The code I’m using is not working, because I get two times the same information (present events). I cannot figure out what I’m doing bad. Someone there can help me?
This is the code I’m using :
<?php $presentevents = eo_get_events(array( 'events_start_before'=>'today', 'events_end_after'=>'today', 'showpastevents'=>false,//Will be deprecated, but set it to true to play it safe. )); if( $presentevents ){ echo '<h2>', 'Eventos en curso', '</h2>'; foreach( $presentevents as $event1 ){ printf("<article><a href='%s' >%s</a> from %s to %s </article>", get_the_permalink($event1->ID), get_the_title($event1->ID), eo_get_the_start('jS F Y', $event1->ID,null,$event1->occurrence_id), eo_get_the_end('jS F Y', $event1->ID,null,$event1->occurrence_id) ); } }else{ echo 'No hay eventos en curso'; } wp_reset_postdata(); ?> <?php $futurevents = eo_get_events(array( 'events_start_after'=>'tomorrow', 'showpastevents'=>false,//Will be deprecated, but set it to true to play it safe. )); if( $futurevents ){ echo '<h2>', 'Eventos futuros', '</h2>'; foreach( $futurevents as $event2 ){ printf("<article><a href='%s' >%s</a> from %s to %s </article>", get_the_permalink($event2->ID), get_the_title($event2->ID), eo_get_the_start('jS F Y', $event2->ID,null,$event2->occurrence_id), eo_get_the_end('jS F Y', $event2->ID,null,$event2->occurrence_id) ); } }else{ echo 'No hay eventos futuros'; } wp_reset_postdata(); ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Troubles Creating a Double Loop in Own Template’ is closed to new replies.