WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Taxonomy filter breaks pagination (4 posts)

  1. icanhazcookies
    Member
    Posted 1 year ago #

    I'm trying to filter the event listing by using a custom taxonomy as described in a couple of other topics, here's my code:

    function filter_events_location($events, $args){
        global $current_location;
    	foreach($events as $event_key => $EM_Event){
    		if(!is_object_in_term($EM_Event->post_id, 'site-location', $current_location))
    			unset($events[$event_key]);
    	}
    	return $events;
    }
    add_filter('em_events_get','filter_events_location',1,2);

    However, this causes the pagination to break in event listings: the plugin creates as many pages as there would have been if the filter was not in place, and on top of that, some pages are blank, since the filter seems to be applying too late ( the plugin counted the unfiltered events for those pages and since the events were removed too late, they are not displayed, but they were still included in the loop ).

    I hope what I've said is clear enough, if not, I guess I could replicate the problem on a development server in order to show you what I mean.

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

  2. icanhazcookies
    Member
    Posted 1 year ago #

    I just finished testing the exact code from this older thread and the problem is in there as well.

  3. agelonwl
    Member
    Posted 1 year ago #

    hi,

    have you tried this tutorial? - http://wp-events-plugin.com/tutorials/creating-custom-event-search-attributes/ (there 2 step)

  4. icanhazcookies
    Member
    Posted 1 year ago #

    Yes, if you take a look at the code I posted you can see that is exactly how it is implemented at the moment. I think I'm going to have to hook into em_events_build_sql_conditions in order for it to work properly, however that's going to be a pretty tricky.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.