Hi!
How can i show my posts in view tables that does not contain data for any custom filed of it.
For example i want to show all posts that dose not have agency title in it.
Agency title is custom filed of posts.
Must let me know
Regards.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
The easiest way is to use the Views filter hook: wpv_filter_query
Please try to add the following code to your current theme's functions.php file.
OR
You can add it to the "Custom Code" section offered by Toolset:
=> https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/
add_filter( 'wpv_filter_query', 'func_custom_field_not_exists_posts', 10, 3 );
function func_custom_field_not_exists_posts( $query_args, $view_settings, $view_id ) {
if($view_id = 999999) {
$query_args['meta_query'][] = array(
'key' => 'wpcf-field-slug',
'compare' => 'NOT EXISTS',
);
}
return $query_args;
}
Where:
- Replace 999999 with your original view ID
- Repalce "field-slug" with your original field slug.
More info:
=> https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query