Support

Home Forums Event Espresso Premium Event Espresso Grid view

Event Espresso Grid view

Posted: December 1, 2017 at 12:43 pm

Viewing 2 reply threads


lroesslein

December 1, 2017 at 12:43 pm

How can I hide sold out events in the Grid View addon – did not find parameter for this.
Thanks Lukas


Josh

  • Support Staff

December 1, 2017 at 2:47 pm

Hi Lukas,

You can remove sold out events with a filter function like this:

function lukas_sold_out_events_where( $SQL, WP_Query $wp_query ) {
	global $wpdb;
	if ( 
		isset( $wp_query->query_vars['post_type'] ) && 
		( $wp_query->query_vars['post_type'] == 'espresso_events'  || 
		( is_array( $wp_query->query_vars['post_type'] ) && 
		in_array( 'espresso_events', $wp_query->query_vars['post_type'] ) ) ) && 
		! $wp_query->is_singular 
	) 
	{
		$SQL .= " AND {$wpdb->posts}.post_status != 'sold_out'";
	}
	return $SQL;
}
add_filter( 'posts_where', 'lukas_sold_out_events_where', 15, 2 );

You can add the above to a functions plugin or into your WordPress theme’s functions.php file.


lroesslein

December 3, 2017 at 7:02 am

Hi Josh,
thanks for fast support! works perfect.
regards Lukas

Viewing 2 reply threads

The support post ‘Event Espresso Grid view’ 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