Skip Navigation

[Resolved] Distance filter for view not working in sidebar (won't save)

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 9 replies, has 2 voices.

Last updated by georgeY-3 2 years ago.

Assisted by: Minesh.

Author
Posts
#2519863

I am trying to:
Add a search filter by distance to a view.

Link to a page where the issue can be seen:
hidden link

I expected to see:
The filter save when I click the button.

Instead, I got:
Nothing. I had the same problem in the last distance filter I used. I had to add it from the block editor, but now I can't remember where to add it from there. I'm hoping the sidebar filter can be fixed so it saves.

On a related note, I'm also trying to filter a view by distance, but the address is from a related post type. In other words, I'm showing a products view and it has the address from the store post type that they are located at. I'm attempting to use this related address field for the map, but it is not working. If you would like a video of this let me know your support email since I can't upload it here.

#2520237

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Do you mean that you want to display the search filter and search result side by side. If that is correct - here is the step information you will require to follow:
- https://toolset.com/course-lesson/creating-a-custom-search/#display-the-search-box-and-search-results-side-by-side

Please let me know if you require further assistance.

#2520477

No, I can't add a filter in the view settings in the sidebar. It won't save. When I click save nothing happens. I think this is a bug.

My second question is I'm trying to add a distance filter to a view with an address field from a RELATED post type. Is that supposed to work?

#2520705

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Do you mean that you have post type X and post type Y with post relationship (one-to-many or many-to-many). And you created a view to display posts belongs to post type X and the map address field for which you want to add distance filter is belongs to post type Y. Is that correct? If yes:
- You can add only fields as frontend filter to your custom search that is belongs to the post type you set your view to query. So, if in your case you set your view to query post type X then you can not add the frontend filter using field that belongs to post type Y.

In some cases - it could be possible to share workaround if possible using custom code but to know if its possible or not we will require to review your current setup. Can you please share what address field you want to use and if I search with XX address what would be your desired result.

Once you share all above required information I will be happy to review your current setup.

#2520941
Screenshot 2022-12-22 114242.png

Yes, you are correct. I do have 2 separate issues, though.

1. Filters will not save from the settings in the sidebar in *any* view I create. I think this is a bug.

2. To answer your question: "Can you please share what address field you want to use and if I search with XX address what would be your desired result."

I have 2 related CPTs:
1. Products
2. Locations

I want to build a product search that shows all products within 50 miles of an address. A good address to try would be:
417 Spaulding Rd, Montezuma, GA 31063

I am using a products view that pulls an address field from the related locations CPT. I want the results to be displayed on a map as well as in a view. Let me know if you need anything else from me.

#2523059

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please check now: hidden link

I've adjusted the view with your page as you can see here: hidden link
- I've set the parent view to query the "Distributors" post type and within the loop I've added another view using the content template and I've added that content template shortcode using the shortcode's block:

[wpv-post-body view_template="ct-for-related-products"] 

Can you please confirm it works as expected now.

#2523185

That's great! Thank you so much for your help. What you did demonstrates a different way of approaching this design, one that I might not have tried on my own. Question: How did you get the filter to save? One of my issues was I couldn't get the filter to save. I must be doing something wrong. Please see the following video:

hidden link

#2523221

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

When you add filter the related query filer will be automatically added and that is why you wont able to save it. Glad to know that the solution I shared help you to resolve your issue.

You're welcome to mark resolve this ticket. Have a great day ahead.

#2523353

Thanks again. In the link to the video I posted in my last comment (hidden link) I'm using a different page set up to not use the relationship. It's just a simple distributor search, but it's still not saving. I can't get a filter to save at all for any view. Here's the test page:

hidden link

#2523371

I am actually able to save filters, just not for the Distance filter. I'm assuming I need to go through the tutorial again to make sure I did everything right. This issue is resolved. Thanks!