Support

Home Forums Event Espresso Premium Sold out events not showing on main event listing

Sold out events not showing on main event listing

Posted: August 17, 2023 at 5:21 am

Viewing 7 reply threads


Bauholz

August 17, 2023 at 5:21 am

Hello,

Events that have a status of ‘Sold out’ are not displaying on my site, and we need them to be visible.

I’m using a plug-in called Ajax Load More (ALM) to display events, and you’ve previously offered help in ensuring that expired events were hidden, by generating a comma-separated list of not-expired event IDs. (See previous forum topic)

I think the cause of the ‘Sold Out’ problem might be that the ALM plug-in is only displaying posts with a status of ‘Published’, and doesn’t recognise the status of ‘Sold Out’. The ID for the sold-out events are being included in the comma-separated list, but the ALM plug-in is not displaying them

Can you suggest a workaround for this? (e.g. reclassify all Sold Out events as Published…?? or anything else?).

Thanks for any help you can give


Tony

  • Support Staff

August 17, 2023 at 4:00 pm

Hi there,

Does ALM have filters for its query args?


Bauholz

August 18, 2023 at 3:35 am

Thanks for your reply Tony.

I’m not totally sure whether ALM offers what you mentioned, but I think it does (e.g. https://connekthq.com/plugins/ajax-load-more/docs/add-ons/filters/hooks/ – is this the sort of thing you mean?).

By default, the ALM plug-in only appears to display posts with a status of ‘published’ or ‘inherit’

I appreciate you can’t support ALM. If you’re not able to offer a workaround, I’d be happy to get in touch with them directly to see if they can help.

If they can’t offer any help, can I ask whether sold out events can just keep their status of ‘published’? I figure that would at least get the events to display… but I’m not sure if (a) this is possible or (b) if it would cause other problems.


Tony

  • Support Staff

August 18, 2023 at 10:05 am

If they can’t offer any help, can I ask whether sold out events can just keep their status of ‘published’?

The short and sweet answer to this is no.

I’d also recommend against going down this route, for the sake of being able to pass a post status to a query your shoehorning Event Espresso functions around.

But let’s see, this may be possible.

Where are you hooking in to pass the event IDs from the previous post?


Bauholz

August 21, 2023 at 6:41 am

This reply has been marked as private.


Tony

  • Support Staff

August 21, 2023 at 9:12 am

It does, your passing the ID’s as a shortcode parameter and not through a filter so it doesn’t help for what I was looking for.

Hmm, so it doesn’t have a way for you to pass the post status, you could filter pre_get_posts but that’s going to run everywhere so then have to do a bunch of checks…

ALM has a filter for the query_args used in the query:

https://connekthq.com/plugins/ajax-load-more/docs/filter-hooks/#alm_query_args

apply_filters( 'alm_query_args_' . $id, $args, $post_id );

You have id="classeslisting" so your ID is classeslisting so try this:

add_filter('alm_qeury_args_classeslisting', 'tw_ee_add_sold_out_status_to_alm', 20, 2);
function tw_ee_add_sold_out_status_to_alm($args, $post_id) {
	$args['post_status'] = array('publish', 'sold_out');
	return $args;
}

Add that to a custom functions plugin, we have some docs on creating on here:

https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/

Note the above is untested just based on the docs.


Bauholz

August 23, 2023 at 7:16 am

Hi Tony,

Thanks – I really appreciate your continued help with this.

Unfortunately the code you suggested didn’t work – the sold_out events continued to be hidden from view.

At this point, should I contact ALM support and see if they can help with displaying posts with a post_status of sold_out?


Tony

  • Support Staff

August 24, 2023 at 5:58 pm

:facepalm:

It didn’t work because there is a typo in my code!

Replace the snippet I gave you above with this….

add_filter('alm_query_args_classeslisting', 'tw_ee_add_sold_out_status_to_alm', 20, 2);
function tw_ee_add_sold_out_status_to_alm($args, $post_id) {
    $args['post_status'] = ['publish', 'sold_out'];
    return $args;
}

My original snippet used alm_qeury_args_classeslisting as the filter name, query is misspelt so the code didn’t run at all but the above works for me.

A couple of bits to note, ALM has a post_status shortcode parameter, which can be set to “any” (post_status="any") within the shortcode…. but… it will only show logged in users a status other than publish.

classeslisting is coming from id="classeslisting" in your shortcode so its specifically targeting that shortcode. However, when testing this locally I was also sometimes getting requests where ID wasn’t set, so the filter wouldn’t run, why I have no idea.

Just to show this working:

https://monosnap.com/file/bjo1O1liXFeHO2ZyYnYEjDjh7ZYHZY

With this shortcode:

https://monosnap.com/file/WCGnJLnzBohcAbE1guvzLpnImCudas

Viewing 7 reply threads

The support post ‘Sold out events not showing on main event listing’ 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