Problem:
The issue here is that the user wanted to filter their view with a query filter to not include posts where the image custom field is empty.
Solution:
This can be done with the hook below.
//Return only products with banner images add_filter( 'wpv_filter_query', 'filter_empty_banners', 99, 3 ); function filter_empty_banners( $query_args,$view_settings ,$view_id ) { if ( $view_id == 44576) { $query_args['meta_query'] = array( array( 'key' => 'wpcf-banner', 'value' => '', 'compare' => '!=' ) ); } return $query_args; }
Add the above to your Toolset custom code section in Toolset -> Custom Code and activate it. You will need to change the 44576 to your view's id as well as the wpcf-banner to the slug of your image field keeping the wpcf- prefix.
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 |
---|---|---|---|---|---|---|
- | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | - |
- | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 14:00 – 18:00 | 13:00 – 18:00 | - |
Supporter timezone: America/Jamaica (GMT-05:00)
This topic contains 4 replies, has 2 voices.
Last updated by 3 years, 8 months ago.
Assisted by: Shane.