Title: Conditional based on scope using PHP
Last modified: October 18, 2018

---

# Conditional based on scope using PHP

 *  Resolved [trestange](https://wordpress.org/support/users/trestange/)
 * (@trestange)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/conditional-based-on-scope-using-php/)
 * I would like to conditionally display event content depending on whether or not
   there is a current or future event. On my homepage I am using the query:
    `<?
   php if (class_exists('EM_Events')) { ?>` to display a list of the 3 most upcoming
   events with `<?php echo EM_Events::output( array('limit'=>3,'order'=>'asc','orderby'
   =>'event_start_date') ); ?>`
 * IF there are no current or upcoming events I would like to show a highlight of
   the 3 latest blog posts. I have the blog posts displaying fine, but I need to
   wrap them into this kind of conditional and can’t seem to find any info on how
   to do this.
 * Thanks in advance!

Viewing 1 replies (of 1 total)

 *  Plugin Support [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * (@angelo_nwl)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/conditional-based-on-scope-using-php/#post-10814199)
 * another way is something like this
 *     ```
       $EM_Events = EM_Events::get( array( 'limit'=>3,'order'=>'asc','orderby'=>'event_start_date' ) );
   
       foreach ( $EM_Events as $EM_Event ){
        if ( $EM_Event->start()->getTimestamp() > time() ){
         echo $EM_Event->output("#_EVENTLINK");
        }
   
       }
       ```
   
 * *this might not work out of the box however it should give you a good start

Viewing 1 replies (of 1 total)

The topic ‘Conditional based on scope using PHP’ 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

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

 * 1 reply
 * 2 participants
 * Last reply from: [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * Last activity: [7 years, 7 months ago](https://wordpress.org/support/topic/conditional-based-on-scope-using-php/#post-10814199)
 * Status: resolved