Home › Toolset Professional Support › [Assigned] filter checkbox
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 0 replies, has 1 voice.
Last updated by alexd-6 6 hours, 37 minutes ago.
Assisted by: Minesh.
Hi, i have a filter for view with: [wpv-control-postmeta field="wpcf-verkauft" url_param="wpv-wpcf-verkauft"]
wpcf-verkauft is an boolean field with empty, 0 or 1. Filled in in the Boxes with red element "VERKAUFT"
i adjust this to "verkaufte Objekte ausblenden ist ein/e boolesch anders als URL_PARAM(wpv-wpcf-verkauft)"
this is german an means "not the same as"
but this is not working.
this is working:
if i try this: verkaufte Objekte ausblenden ist ein/e boolesch gleich URL_PARAM(wpv-wpcf-verkauft)
this means same like in db - 1
now its set to "same like" and it shows all "wpcf-verkauft"=1, but i want to hide all "wpcf-verkauft" if checkbox in filter is clicked.
i hope, you understood my message 😉
best regards - alex
Hello. Thank you for contacting the Toolset support.
I need to check your current settings and what view you created.
Can you please share problem URL and admin access details.
*** 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 have set the next reply to private which means only you and I have access to it.
As I understand - you want to hide the posts from the following page where "verkaufte Objekte ausblenden" checkbox field is checked in backend when user select the filter "verkaufte Objekte ausblenden" on the following page:
Can you please check now: hidden link
I've added the following code to "Custom Code" section offered by Toolset:
=> hidden link
add_filter( 'wpv_filter_query', 'func_exclude_verkaufte_sold_objects_posts', 99 , 3 ); function func_exclude_verkaufte_sold_objects_posts( $query_args, $view_settings, $view_id ) { if ( $view_id == 1959 ) { if(isset($_GET['wpv-wpcf-verkauft']) and $_GET['wpv-wpcf-verkauft']==1) { $target_post_type = "objekt"; $args = array( 'posts_per_page' => -1, 'fields' => 'ids', 'post_type' => $target_post_type, 'meta_query' => array('key'=>'wpcf-verkauft', 'value'=>1, 'compare'=>'='), 'post_status' => 'publish', ); $posts_array = get_posts( $args ); $query_args['post__not_in'] = $posts_array; } } return $query_args; }
More info:
=> https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/
=> https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
Can you plese confirm it works as expected.
Hi Minesh - thx for your help.
You understand it what i want, but it does not work correctly. - When i check ""verkaufte Objekte ausblenden" - But the Objects with "verkauft" are visible again. - And if i click on search "suchen" i will be redirected to XML Sitemap -> hidden link
i dont know why.. - can you help me again?
best regards - alex
ok - I've adjusted the code so you will not see any posts when you click on ""verkaufte Objekte ausblenden" and filter the results.
add_filter( 'wpv_filter_query', 'func_exclude_verkaufte_sold_objects_posts', 99 , 3 ); function func_exclude_verkaufte_sold_objects_posts( $query_args, $view_settings, $view_id ) { if ( $view_id == 1959 ) { if(isset($_GET['wpv-wpcf-verkauft']) and $_GET['wpv-wpcf-verkauft']==1) { $target_post_type = "objekt"; $args = array( 'posts_per_page' => -1, 'fields' => 'ids', 'post_type' => $target_post_type, 'meta_query' => array('key'=>'wpcf-verkauft', 'value'=>1, 'compare'=>'='), 'post_status' => 'publish', ); $exclude_posts_array = get_posts( $args ); $meta_query = $query_args['meta_query']; foreach($meta_query as $k=>$v): if($v['key']=='wpcf-verkauft'){ $found_index=$k; break; } endforeach; unset($meta_query[$found_index]); $query_args['meta_query']=$meta_query; /* $query_args['meta_query'][]=array('key'=>'wpcf-verkauft', //'value'=>'0', 'compare'=>'NOT EXISTS'); */ //unset($meta_query[$found_index]); $query_args['post__not_in'] = $exclude_posts_array; //$query_args['post__in'] = $posts_array; } } return $query_args; }
Is this expected result?
Do you want to include any posts when you click on the "verkaufte Objekte ausblenden" filter? if yes: what posts should be included?
I do not understand yet when you click on the checkbox filter "verkaufte Objekte ausblenden" and apply the search button - you want to remove/hide the posts where "verkaufte Objekte ausblenden" checkbox is checked on backend edit post?
I just do not understand you exact requirement yet. I see you are using following code to display the "verkauft" lable.
[wpv-conditional if="( $(wpcf-verkauft) ne '' )"]<div class="kaufzusage verkauftbox">verkauft</div>[/wpv-conditional]
Hi Minesh, -
i correct it - you are right - but the checkbox in filter shows now all items with "verkauft" - i should be "if filter checkbox checked, hide all "verkauft" - in that moment is: all "verkauft" is visible "all not verkauft" is hiding.
thx for helping, alex
As you are using production site we do not recommend to debug on live site. Can you please setup a staging/test site where I can activate/deactivate plugins and theme.
In addition to that - I found that you are using outdated Toolset plugins. We always recommend running your site with the latest stable release plugin version.
*** Please make a FULL BACKUP of your database and website.***
Could you please update ALL Toolset plugins to it's latest officially released version. You can download the latest plugin release from your accounts page:
=> https://toolset.com/account/downloads/
Hi Minesh - yes i updated the Plugins and i have backups. And i have a staging.dumberger-bau.de. Can i send you login-credentials? - best regards - alex
*** 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 have set the next reply to private which means only you and I have access to it.