Ready to get started?Download WordPress


Events Manager
[resolved] [REQ] Add limit to lists of events such as #_LOCATIONNEXTEVENTS (3 posts)

  1. Daedalon
    Posted 1 year ago #

    In classes/em-location.php line 725 says what I've been hoping for a while:

    //TODO: add limit to lists of events

    I wanted to bump this one in case you found it'd be easy enough to implement this in core. I think the best way would be to support the number as an argument, eg. #_LOCATIONNEXTEVENTS{10} would show a maximum of ten upcoming events.

    I tried making a custom placeholder that would have a fixed limit. However, I wasn't able to get it working. I tried replacing:

    $events = EM_Events::get( array('location'=>$EM_Location->location_id, 'scope'=>$scope) );


    $events = EM_Events::get( array('location'=>$EM_Location->location_id, 'scope'=>$scope, 'limit'=>10) );

    both with and without surrounding the number in quotes and using a variable to pass the number. The added limit parameter had no visible effect. I had high hopes it would due to this line inside classes/em-events.php, function EM_Events::get, line 58:

    $limit = ( $args['limit'] && is_numeric($args['limit'])) ? "LIMIT {$args['limit']}" : '';

    In my further testings I found to my surprise that if I added below this eg. $limit = 'LIMIT 5'; the limit that took effect was that number times two: 'LIMIT 5' showed 10 events, 'LIMIT 10' showed 20 and so on.


  2. agelonwl
    Posted 1 year ago #

    maybe this snippet will give you an idea -> http://pastebin.com/MhkCLJkE

  3. Daedalon
    Posted 1 year ago #

    Thanks a lot, that worked!

    I was able to locate the issue. It was on the line that was originally line 736 from classes/em-location.php:

    $replace .= get_option('dbem_location_event_list_item_header_format');

    Removing the "." from the custom placeholder made the limit parameter take effect.

    Marcus: Should that dot be removed from core? I tried removing it from core and disabling custom placeholders and couldn't notice any change in behavior. Removing that shortcode seems necessary when you'll work on adding the support for limit as a parameter for the shortcode such as #_LOCATIONNEXTEVENTS{10}. Not remembering to remove the dot then can cause some headache trying to figure out why the new parameter doesn't work.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic


No tags yet.