Home Forums WP User Integration per_page parameter not working in My Events

per_page parameter not working in My Events

Posted: May 13, 2019 at 10:06 pm


May 13, 2019 at 10:06 pm

Hi there, I implemented this code snippet in my content-espresso_my_events-event_section.template.php file from another post a little while back to only show the upcoming events in our members ‘My Events’ page using the [ESPRESSO_MY_EVENTS] shortcode:
if ( $event->get_active_status() != 'DTU' ) { return; }

It was working fine but now noticing that the per_page parameter doesn’t take effect anymore and if I use something like this: [ESPRESSO_MY_EVENTS per_page=15], no events show up at all. Also, if I don’t specify the per_page only 3 events are showing up total, but we need to see more than that.

How can we show more events or fix this little issue? Thanks for any help.


  • Support Staff

May 14, 2019 at 5:11 am

Hi there,

This code:

if ( $event->get_active_status() != ‘DTU’ ) { return; }

Is basically filtering the events AFTER they have been queried, so what it sounds like is happening is your per_page limit is pulling 15 events from the database and the above then checks if the active status is upcoming (‘DTU’) and as they are not, skipping them.

So say I asked you to grab 15 books from a shelf, then after you’ve picked those up I went through and only wants books based on X, any books not based on X, I simply throw them on the floor and if none of them are based on X you now have 0 books in your hand to do something with.

The books in the above are your events and X is the code above checking for a status of DTU.

If you remove the code or simply comment out return;, so its //return;, do you see the 15 events on each page as expected (regardless of their status)?

If so per_page is working as expected, the above is the problem and your events are all being ‘filtered’ out after they’ve been pulled form the database.


May 14, 2019 at 9:51 pm

OKay yes it worked when I commented out ‘return’. So how can I get this working correctly where per_page works AND only shows the upcoming events for the member?


  • Support Staff

May 15, 2019 at 8:28 am

Currently, you can’t, at least not without modifying the plugin (not the templates) to allow you to do so. You need to alter the parameters used for the query to define the type of events to pull before filtering them.

I’ve created a ticket to add a filter to the add-on which can then be used for this, it will need to reviewed and tested before it’s included in add-on.


May 21, 2019 at 11:16 pm

Okay thank you for that. One follow up, though. Somewhere it is deciding to pull 3 events at a time. Is there no way to modify that in the code somewhere so that it pulls more than 3 events at a time?



  • Support Staff

May 22, 2019 at 3:53 am

You mean when you don’t set the per_page attribute?

The per_page parameter sets the number of events it pulls on each page and defaults to 10 when not set, again if you have the code above in place it will filter the events after they’ve been pulled from the database which could mean it displays less events than that as they’ve been filtered out.

The support post ‘per_page parameter not working in My Events’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso