Support

Home Forums Event Espresso Premium show_expired = TRUE is not showing events that are sold out.

show_expired = TRUE is not showing events that are sold out.

Posted: October 30, 2017 at 6:06 pm

Viewing 5 reply threads


extima

October 30, 2017 at 6:06 pm

Is there a way to display events that are Sold Out?

On our home page we are displaying a few events that have been tagged Featured, some are sold out, but we still want to display them, as people can wait list but this parameter is not allowing them to come through.


Tony

  • Support Staff

October 31, 2017 at 2:35 am

Hi there,

Can you let me know how you are displaying the events on your home page?

I’m guessing using the [ESPRESSO_EVENTS] shortcode?


extima

October 31, 2017 at 3:09 pm

Hello Tony I’ve actually created my own shortcode essentially because I needed different functionality and more freedom than I was finding with [ESPRESSO_EVENTS].
Here is how I’m calling the events:

$args = array( 'post_type' => 'espresso_events','tag' => 'Featured', 'post_status' => 'publish', 'show_expired' => TRUE, 'meta_key' => 'start_date', 'orderby' => 'meta_value_num', 'order' => 'ASC', 'posts_per_page' => 6 );

But I’ve also tried:

$args = array( 'post_type' => 'espresso_events','tag' => 'Featured', 'post_status' => 'publish', 'show_expired' => 'true', 'meta_key' => 'start_date', 'orderby' => 'meta_value_num', 'order' => 'ASC', 'posts_per_page' => 6 );

and neither seem to work. Sold Out events will not display.


Josh

  • Support Staff

October 31, 2017 at 3:17 pm

Quite likely the 'post_status' => 'publish' part of your query is filtering out any sold out events, those have a different post_status. As an aside, the start date of the event is not stored in postmeta. So if the events aren’t getting ordered by the start date, you can use the model system to do a query that will order by the event start date. There’s an example in this gist:

https://gist.github.com/joshfeck/6e33532c37a123bbf532


Tony

  • Support Staff

October 31, 2017 at 3:27 pm

Ok, thank you.

So those are the args your passing, but are you just simply passing those to WP_Query? If so it won’t know what show_expired is.

However, show_expired isn’t for pulling in sold events as they aren’t expired, expired events are events with an event end date in the past.

I’d recommend using our models to pull the events:

https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System

Sold out events change their post status from publish, so this 'post_status' => 'publish' is actually preventing you from pulling those events but the modesl handle most of this for you anyway.


extima

October 31, 2017 at 3:43 pm

Thanks guys, I actually didn’t even consider the fact that it was changing the post status, completely overlooked it. I just created an array for the post status parameter and included ‘sold_out’ and now it’s working. Thanks!

Viewing 5 reply threads

The support post ‘show_expired = TRUE is not showing events that are sold out.’ 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