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 ?
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.
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).
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.
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?
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.
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;
}