Skip Navigation

[Resolved] Loop Output Editor Conditional Output not working

This support ticket is created 6 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 7 replies, has 2 voices.

Last updated by Minesh 6 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#616087
Screenshot 2018-02-14 17.45.00.png

I am using Toolset and Views along side with Event Espresso plugin.
With Toolset i have made an archive page for the Events.
Filters work output is showing all the events,
- but when an event is sold out it changes its status from publish to sold_out.
- In this case the query works only with events whose status is set to publish. I have tried using a conditional output with 2 conditions where the wpv-post-status is publish or sold_out yet i am still not getting events that are sold out.
- I have tried using only 1 statement where wpv-post-status is set to "sold_out" and i am not getting anything. But if i use only 1 statement with wpv-post-status is set to "publish" i am getting all the events except the ones that are sold out .
can anyone please help ?

#616223

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

By default view's add posts with post status equal to publish.

What you should try to do here is, go to "Query Filter" section of your view and try to add a new filter "Post status" and select your required post status you want to include and save your filter.

More info:
https://toolset.com/documentation/user-guides/filtering-views-query-by-post-status/

#616255
Screenshot 2018-02-15 09.52.33.png
Screenshot 2018-02-15 09.50.56.png
Screenshot 2018-02-15 09.41.26.png

Hi Minesh, thank you for your answer....i did work, but not 100%, the following is happening:

the filter works but the list of available posts statuses contains only the ones set by WP....as mentioned i am using Events Espresso plugin. Once an Event is sold out the plugin automatically sets the post_status to sold_out.

The sold_out status is not available in the list of statuses. I can though select: any: but in this case all posts are being shown, events that are trashed or draft, and this is where my issue lies now.

Another solution would be to create a custom field and add a filter according to that field but another issue rises here: i can not set a custom filed on the espresso_events post type ( once again it is not present in the list of available posts).

#616260

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please share one event URL which have been assigned the status sold out?

Also, which view you are using to display the posts and to which page you have added this view. Could you please share all required details I asked and I'm happy to help you further:

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#616373

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I checked and I see there is lot of issues with sold_out status with other users as well with espresso event plugin on their forum.

Could you please contact them and ask them how you can include sold_out events to event archive page?

#616397

So is this list generated dynamically by Types Toolset or are they fixed values? If so any custom post_status would never appear in the list or am I wrong?

#616405

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - it depends how your plugin author has added the post status. We generally display all post status that by default supported by wordpress.

It needs some hook to apply like "pre_get_posts" OR "posts_where" but you need to consult your plugin author how you can apply the sold_out post status to your event archive page.

#616406

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I tried this but its not working - so please check with your plugin author:

Following code should work but not working:

 add_filter( 'posts_where', 'posts_where_statement' );
 function posts_where_statement( $where = '' ) {
	//gets the global query var object
	global $wp_query;
	global $wpdb;
	
	 
	 if (!is_admin() && $wp_query->is_post_type_archive('espresso_events') && $wp_query->is_main_query() ) {
		 
		$where =  " AND ".$wpdb->prefix.".post_type = 'espresso_events' AND ((".$wpdb->prefix.".post_status = 'publish' OR ".$wpdb->prefix.".post_status = 'private' OR  ".$wpdb->prefix.".post_status = 'sold_out' ))";	
	
		 
	 }
 
	return $where;
}