WordPress.org

Forums

Events Manager
[resolved] Can EM sort unique events from recurring events? (11 posts)

  1. debsch
    Member
    Posted 3 years ago #

    Hello again!

    EM is working wonderfully on my site. But the once-off, unique events are being a little cluttered out by weekly events. There are so many weekly events that you can't easily see the really special once-off events that are coming up.

    So I was wondering if there is a way to sort them?
    Like you can display events from a certain category, or events for just tomorrow, etc... Is there a way to display JUST unique events and so I can have a separate page for weekly/recurring events?

    Thank you!!

    http://wordpress.org/extend/plugins/events-manager/

  2. agelonwl
    Member
    Posted 3 years ago #

    try this previous post which uses a scope="this-week" - http://wordpress.org/support/topic/plugin-events-manager-creating-custom-scope-for-events-widgets?replies=7 maybe you can create a new scope for next-week.

  3. debsch
    Member
    Posted 3 years ago #

    Thanks for the reply. So you're suggesting I create my own 'scope'? One for recurring events?

    Where in the DB will I find a field that says something like 'event-type' = 'recurring' or 'event-type' = 'single'?

    If I can find that, I'll be able to just pull out the single events and put the recurring events on a separate page.

  4. agelonwl
    Member
    Posted 3 years ago #

    or another way is to check for the $EM_Event->recurrence_id

  5. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 3 years ago #

    recurrence_id in the database will have a number higher than 0 or not null if it's recurring.

  6. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 3 years ago #

    that's in the wp_em_events table

  7. debsch
    Member
    Posted 3 years ago #

    Thanks for the help. I can see how this would work. Haven't got the time to try it out today but will mark this post as resolved.

  8. debsch
    Member
    Posted 2 years ago #

    Ok, 3 months later, *now* I have some time...

    1. I've added this to my functions.php

    add_filter( 'em_events_build_sql_conditions', 'unique_em_scope_conditions',1,2);
    function unique_em_scope_conditions($conditions, $args){
    	if( !empty($args['scope']) && $args['scope']=='futureunique' ){
    		$conditions['scope'] = " recurrence_freq!='weekly' AND recurrence_freq!='daily'";
    	}
    	return $conditions;
    }

    2. I've changed the events manger settings to use shortcodes instead of one specific page to display events

    3. I've created a new page and added this title & shortcode to the page

    Unique events
    [events_list scope='futureunique']

    The resulting page does not show daily/weekly events it only shows monthly events.

    Also, the resulting page does not show UNIQUE events because in the database 'recurrence_freq' for unique (one-off) events appears as NULL.

    Could someone please help with:

    1. The correct code to add here to display the entries that have recurrence_freq = NULL

    $conditions['scope'] = " recurrence_freq!='weekly' AND recurrence_freq!='daily'";

    2. The code to add to display FUTURE events (that are not weekly/daily).

    Of course if I figure it out myself in the meantime I will add the solution here. Thanks.

  9. debsch
    Member
    Posted 2 years ago #

    So (thanks google) this is what works for me...

    add_filter( 'em_events_build_sql_conditions', 'unique_em_scope_conditions',1,2);
    function unique_em_scope_conditions($conditions, $args){
    	if( !empty($args['scope']) && $args['scope']=='futureunique' ){
    		$conditions['scope'] = " (recurrence_freq = 'monthly' OR recurrence_freq IS NULL)";
    	}
    	return $conditions;
    }

    Still need help with filtering out past events and only displaying future events in this custom scope.

  10. debsch
    Member
    Posted 2 years ago #

    Can anyone help with filtering out past events and only displaying future events in this custom scope?

  11. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    I advise you not override the 'scope' array key and add a new key. the way you´re doing it now overrides the normal scope function, so what I'd so is add a new search attribute like 'unique' and then add your sql, then you use still scope="future" and then add an extra sql rule.

    much like the styles example in our tutorials

    apart from that, it looks correct to me. hope that helps!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Events Manager
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic