Tell us what you are trying to do? I need the post type field to show up in the URL query string when a post type is selected. I have AJAX on and automatically update URL when selecting an option. All other filters show up in URL except for the post type. Post type will only show if I manually click on the submit button, but I would like it to work with AJAX.
Is there any documentation that you are following? No
Is there a similar example that we can see? hidden link
Hello and thank you for contacting the Toolset support.
I wonder how did you build this post-type filter? Toolset does not offer a post-type filter in the view's search form. I assume that you have created it manually, right?
And how do you alter the view's query? I assume that you are using custom PHP code, right? Can you share this code?
In the meantime, you can use the view's Javascript event to update the page URL. You can rely on the "js_event_wpv_parametric_search_results_updated" event, but you need to defer your code for some time (100ms) because Toolset updates the page URL after firing this event.
jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated', function( event, data ) {
/**
* data.view_unique_id (string) The View unique ID hash
* data.layout (object) The jQuery object for the View layout wrapper
*/
setTimeout(function(){
// code here to update the URL
}, 100)
});
But, this does not guarantee that the post type will be used if the user refreshes the page. I am not sure if the custom code handles the first load case.
For a reference on how to change the URL parameters, you can check this reply https://stackoverflow.com/a/41542008
Thanks Jamal, for the code. I'll test out the javascript.
As for the php code. Yes, we added a script to the functions.php code. Most of the code we found in the Toolset forum from one of the Support Rep's response to another ticket. I'll dig up the php code for you soon, once I implement the code above.
Awesome. Let me know if you need further help. In the meantime, I'll set this ticket as waiting for your feedback, which should keep it open for 3 weeks. You will receive an email notification before the system closes the ticket.