Skip Navigation

[Closed] When selecting a post type in my view it doesn't update in URL

This support ticket is created 3 years ago. There's a good chance that you are reading advice that it now obsolete.

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
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9: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: Africa/Casablanca (GMT+01:00)

This topic contains 5 replies, has 2 voices.

Last updated by Jamal 2 years, 11 months ago.

Assisted by: Jamal.

Author
Posts
#2016629

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

What is the link to your site? hidden link

#2017041

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

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

#2018923

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.

#2019287

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

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.

#2027587

Hi Jamal. Looks like this ticket was closed before the 3 weeks you allowed. Can you extend it still?

#2071967

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

My apologies, I just saw this message. So, I checked your profile to see if you have created another ticket and I could not find any.

I am reopening this ticket, please let me know how I can help further.

The topic ‘[Closed] When selecting a post type in my view it doesn't update in URL’ is closed to new replies.