Support » Plugin: Events Manager » [Plugin: Events Manager] Long events display using shortcodes

  • Resolved gabejamison


    Hey everyone, I’m using shortcodes to display a specific category of events, but I’m having a little problem. My events in this category last for several months. I’m trying to separate them out using these event date ranges (Current, Future, Past). I was able to get current and past working using scope=”today” and scope=”past” respectively, my problem is with the future scope. The future scope doesn’t use the start date, as far as I can tell, because it is showing current events that end in the future. I’d like it to only show events that haven’t started yet. I’ve tried scope=”today+1″ and scope=”>today” which both break and just display all events. Anyone have an idea how I can display a group of events that haven’t started yet?

Viewing 15 replies - 1 through 15 (of 21 total)
  • Plugin Author Marcus


    There’s a setting for that in settings – Are current events past events?

    Yeah I know about that setting, but I was speaking of current events that last for several more months. I didn’t want them to show up as current events and future events (because of the end date). I created a new scope however and I was able to achieve what I wanted.

    add_filter( 'em_events_build_sql_conditions', 'my_em_scope_conditions',1,2);
    function my_em_scope_conditions($conditions, $args){
    	if( !empty($args['scope']) && $args['scope']=='future-start' ){
    		$start_date = date('Y-m-d');
    		$conditions['scope'] = " (event_start_date > CAST('$start_date' AS DATE))";
    	return $conditions;
    add_filter( 'em_get_scopes','my_em_scopes',1,1);
    function my_em_scopes($scopes){
    	$my_scopes = array(
    		'future-start' => 'Future Start'
    	return $scopes + $my_scopes;

    Then I called [events_list scope="future-start" category="2"]
    and was able to only pull future events that have not started yet.

    thanks for sharing!

    I think I have a use for this code as well!

    Plugin Author Marcus


    thanks for sharing, but isn’t that what setting I mentioned do this?

    that setting should only consider events as current if the start date is later than your search day, i.e. they haven’t already started.

    Perhaps it should not always be global….?
    But yes, globally, your settings would do the job.
    My recurring event problems are much more complex as you know 😉 and a recent post even wants long events with different times per occurrence…

    Plugin Author Marcus


    confused, what do you mean by global?

    EM Settings are global for events listing. With shortcodes you sort of create your own events lists, overriding the default/global of the settings, right ?

    I have “Are current events past events” set to no. But current events still show up as future events (when the end_date is after today), so I’m not sure if that’s what you wanted the plugin to do, or maybe I am not being clear in what I was trying to do.

    My list of events:
    Event 1: Start two months ago, end yesterday (past)
    Event 2: Start yesterday, end two months from now (past, current & future)
    Event 3: Start tomorrow, end two months from now (future)

    I wanted to list these events in groups according to when they occur (Current, Future, and Past)

    Before my list looked like this:
    Current Events
    Event 2
    Future Events
    Event 2 (shouldn’t show up here, because it is a current event)
    Event 3
    Past Events
    Event 1

    Event 2 did not show up as a Past Event because I have the “Are current events..” setting set to no, but it still showed up under Future Events. I created the scope setting, and was able to display only events that have not started yet as Future Events.

    Event 2 reaches in the future and that is why it is possibly marked also as future. It would help if there would be a clear “running” or current events definition. Event 2 should not be repeated as future event as the start date is passed (cannot book anymore), I agree .

    Plugin Author Marcus


    @shonu, i see what you mean. could probably make this an attribute eventually

    maybe it’s a bug, i would think that setting ‘are current events past’ to yes would remove #2 from future events, as it already started and is therefore past.

    will check it out

    Plugin Author Marcus


    Just tested this, if I make an event start in the past and end in the future, if you show a list of future events and flick that setting on/off, the event disappears accordingly.

    could it be you’ve altered the SQL making your own changes?

    I haven’t changed the SQL statements. But I wonder, will Event 2 now show up under Current Events and Past Events? All these lists are on one page so any duplication would be awkward. My idea of current is today or right now regardless of when it started or stops. Otherwise if it’s not happening today it should be defined as past or future. I can test your suggestion later today.

    I tried it with “are current events…” set to Yes, and the results were a little worse than expected, the events were not displayed as Current Events and only in Past Events. It’s really okay though, I got it working with my custom scope so hopefully if anyone else runs into the same issue they can use my code to help out.

    Maybe in a future release you can address the issue if enough people are looking at doing the same thing. For me anyway:
    Past = Started in the past, ended in the past
    Current = Happening right now, regardless of when it started or ends
    Future = Has not started or ended.

    I know these definitions are general and may not apply to everyone, but they might help get a conversation going on the subject.

    Plugin Author Marcus


    will test this again when time permits, this can be confusing without live examples 🙂

    anyone else having a problem with this?

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘[Plugin: Events Manager] Long events display using shortcodes’ is closed to new replies.