I am trying to filter a list of posts by only 2 terms of a category taxonomy that has a total of 7 terms.
I would like the filter to be a dropdown with 3 choices:
Please select (any)
PR Story
Research Story
hidden link
This is the code I am using for the filter:
[wpv-control url_param="wpv-category" type="select" values="0,pr-story,research-paper" display_values="Please Select,PR Story,Research paper" default_label="Please Select"]
I have 2 additional dropdown filters (for Labs and Services). The Category dropdown does not work set to the default of any, when the other filters are used.
It will work with the other filters if PR Story or Research Story is selected.
I noticed the url when another filter is used with Category set to the default is the following:
hidden link
If I manually edit this url in the browser to remove %5B%5D, it displays the proper results. How can I stop the view from inserting %5b%5D in the url?
I noticed this similar issue but I did not see how it was resolved: https://toolset.com/forums/topic/vpv-control-not-working-anymore-after-update/#post-238885
Hi,
Thank you for contacting us and I'd be happy to assist.
To troubleshoot this on my test website, I'll need to see exactly how this view is set up in the admin area.
Can you please share temporary admin login details, in reply to this message?
Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.
regards,
Waqar
Thank you for sharing the admin access.
Just wanted to let you know that I'm currently running some tests on my website with a similar view and will be able to share my findings shortly.
Thank you for your patience.
Thank you for waiting.
During troubleshooting, I noticed that the "News" view is using the "wpv-control" shortcode (which works for custom fields) and not the "wpv-control-post-taxonomy" shortcode (which works for taxonomies), for the "Category" taxonomy field.
Current category field shortcode:
[wpv-control url_param="wpv-category" type="select" values="0,pr-story,research-paper" display_values="Please Select,PR Story,Research paper" default_label="Please Select"]
To fix this, you can replace that shortcode with the "wpv-control-post-taxonomy" shortcode:
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-control-post-taxonomy )
[wpv-control-post-taxonomy taxonomy="category" type="select" default_label="Please Select" url_param="wpv-category"]
Since the "wpv-control-post-taxonomy" shortcode doesn't support filling in only the selected taxonomy terms as options, you can remove the un-wanted options from the select field, by adding some custom script in the view's "JS editor":
jQuery(document).ready(function(){
jQuery('select[name="wpv-category"] option').each(function() {
if ( (jQuery(this).val() != '0') && (jQuery(this).val() != 'pr-story') && (jQuery(this).val() != 'research-paper') ){
jQuery(this).remove();
}
});
});
This script will remove all options from the category select field, except for the default, PR Story, and "Research paper".
My issue is resolved now. This is great! Thank you so much!