Hi Support
I have a dropdown in a search form for selecting a custom post type. The search works regardless of what I select the first time. But after that, the selection does not work. It seems as though the URL is get longer each time, with multiple instances of the parameters being added to the end.
I am using this code in my functions file that I found on your forums:
{code}
add_filter( 'wpv_filter_query', 'post_type_filter_func', 10, 3 );
function post_type_filter_func( $query_args, $settings, $view_id ) {
if ( $view_id == 36220 && isset($_GET['wpv-post-type'][0]) && !empty($_GET['wpv-post-type'][0]) ) {
$query_args['post_type'] = $_GET['wpv-post-type'][0];
}
return $query_args;
}
{/code}
This is the form info I have in my view.
{code}
[wpv-control url_param="wpv-post-type" type="select" values=",journal-article,policy-issue,research-report" display_values="All,Journal Articles,Policy Analysis,Research Report" class="search-research-and-resources-dropdown"]
{/code}
If I select any of these items the first time it works fine. But any change to the dropdown and clicking the submit button again, causes the parameters to continue to be added to the url. I believe the function code is picking up the first occurrence of wpv-post-type since I see that being added each time.
See URL examples below.
FIRST SEARCH SUBMISSION (Select Journal Articles):
hidden link
SECOND SEARCH SUBMISSION (Select Policy Analysis - Results stay on Journal Articles - 1st item)
hidden link
THIRD SEARCH SUBMISSION (Select Research Reports - Results stay on Journal Articles - 1st item)
hidden link
How do I get this url to reset after I select a new item in the dropdown and submit the search again?
Just a note: This was working fine. But we updated the plugin a couple of days ago. Could that have caused this to break? Not sure if that caused this?
Thanks!