Title: Using conditional statements to display events
Last modified: August 30, 2016

---

# Using conditional statements to display events

 *  Resolved [sktwentysix](https://wordpress.org/support/users/sktwentysix/)
 * (@sktwentysix)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/using-conditional/)
 * Okay, I hope I can convey the issue I have well enough.
 * I have 3 colomns, with each column displaying a single event. So a maximum of
   3 events will be displayed on the page at once with the left most being the next
   upcoming event, the middle displaying the next event with an offset of 1, the
   rightmost displaying the next event with an offset of 2.
 * This all works just fine! However, in the case where there are only 2 events 
   or less to display, I want the empty column or columns to display something else
   in its place.
 * Here is the code I have in my page template PHP file:
 *     ```
       add_action( 'genesis_before_entry', 'nsg_homepage_header' );
       function nsg_homepage_header() {
       echo '<div class="event-header"><div class="wrap">';
       if (class_exists('EM_Events')) {
       	echo '<div class="event-header-block one-third first entry">';
       	echo EM_Events::output(
       		array('limit'=>1,
       			'orderby'=>'date',
       			'format'=><div>EVENT INFO OUTPUT</div>
       		)
       	);
       echo '</div>';
       }
       else {
       	echo '<div>REPLACEMENT HTML GOES HERE</div>';
       }
       if (class_exists('EM_Events')) {
       	echo '<div class="event-header-block one-third entry">';
       		echo EM_Events::output(
       			array('limit'=>1,
       				'offset' =>1,
       				'orderby'=>'date',
       				'format'=><div>EVENT INFO OUTPUT</div>
       			)
       		);
       	echo '</div>';
       }
       else {
       	echo '<div>REPLACEMENT HTML GOES HERE</div>';
       }
       if (class_exists('EM_Events')) {
       	echo '<div class="event-header-block one-third entry">';
       		echo EM_Events::output(
       			array('limit'=>1,
       				'offset' =>2,
       				'orderby'=>'date',
       				'format'=><div>EVENT INFO OUTPUT</div>
       			)
       		);
       	echo '</div>';
       }
       else {
       	echo '<div>REPLACEMENT HTML GOES HERE</div>';
       }
       echo '</div></div>';
       }
       ```
   
 * PHP is not my forte, so I hope you can forgive my messy code.
    Each if else statement
   outputs the event with a particular offset to one column, and I want it to output
   the else statement if an event doesn’t exist in that particular column, but I
   don’t know how to do it (e.g. if there are just 2 events to display, the column
   with an offset of 2 isn’t going have anything to display, so I want something
   else to replace it.
 * Many thanks for any help you can provide! 🙂
 * [https://wordpress.org/plugins/events-manager/](https://wordpress.org/plugins/events-manager/)

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

 *  [caimin_nwl](https://wordpress.org/support/users/caimin_nwl/)
 * (@caimin_nwl)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/using-conditional/#post-6406658)
 * You could try something like this:
 *     ```
       if( EM_Events::output(
       	array('limit'=>1,
       			'orderby'=>'date',
       			'format'=><div>EVENT INFO OUTPUT</div>
       		)
       	)) {
   
       	echo EM_Events::output(
       		array('limit'=>1,
       			'orderby'=>'date',
       			'format'=><div>EVENT INFO OUTPUT</div>
       		)
       	);
   
       } else {
   
       echo '<div>REPLACEMENT HTML GOES HERE</div>';
   
       }
       ```
   
 *  Thread Starter [sktwentysix](https://wordpress.org/support/users/sktwentysix/)
 * (@sktwentysix)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/using-conditional/#post-6406668)
 * Dude, thank you so much! Thanks to this, I managed to get it working the way 
   I wanted it to.
 * And I hope my atrocious code wasn’t to taxing to read.
 * Thanks again 🙂

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

The topic ‘Using conditional statements to display events’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=3550347)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

## Tags

 * [conditionals](https://wordpress.org/support/topic-tag/conditionals/)

 * 2 replies
 * 2 participants
 * Last reply from: [sktwentysix](https://wordpress.org/support/users/sktwentysix/)
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/using-conditional/#post-6406668)
 * Status: resolved