Skip Navigation

[Resolved] Location Filter Problems

This thread is resolved. Here is a description of the problem and solution.

Problem: I am trying to use a distance filter in a WordPress Archive but it does not seem to be working.

Solution: Distance filters in WordPress Archives are not currently functional. We hope to fully support this feature in an upcoming release, but for now, the best approach is to create a View with a distance filter and insert it in a WordPress Archive. Remove everything in the wpv-loop tags of the Wordpress Archive's Loop Output editor.

0% of people find this useful.

This support ticket is created 6 years, 6 months 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 22 replies, has 2 voices.

Last updated by Christian Cox 6 years, 6 months ago.

Assisted by: Christian Cox.

Author
Posts
#868672
screenshot5.jpg
screenshot4.jpg
screenshot3.jpg
screenshot2.jpg
screenshot1.jpg

I am trying to: Filter posts by location

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

I expected: Posts to be sorted by their location data provided by the Toolset Address field.

Instead, I'm only receiving search query feedback, and no results for location searching.

All Toolset plugins are up to date, along with WordPress and the Divi theme. I'm also using a plethora of other plugins, most notably GeoDirectory and Relevanssi Premium.

I am attempting to create a directory listing site that lists dogs that can provide frozen assets to clients. Each dog has a location associated with it, so that a user may search for a dog breed in their area.

I created a layout that contains a WordPress Archive cell that is configured to allow customized searching and filtering. I've been able to successfully filter my posts with the taxonomy filters so far. When I started noticing that location data provided by GeoDirectory was not making it through to the archive's filtered results, I figured I could rely on Toolset's location fields data to achieve what I was looking to do.

Here's what I have:

I created the appropriate URL parameters via the Filter Editor with the following shortcodes:

[wpv-filter-search-box output="bootstrap"]
[wpv-control-distance default_distance="20" default_unit="mi" compare_field="address" distance_center_url_param="toolset_maps_distance_center" distance_radius_url_param="toolset_maps_distance_radius" distance_unit_url_param="toolset_maps_distance_unit" inputs_placeholder="%%DISTANCE%% %%CENTER%%"]

I then, replicated these fields in a different cell with my own fields referring to the same URL parameters:

<form id="breed-search" method="GET" action="/dogs">
<input type="text" name="wpv_post_search" placeholder="Search Dog Breed">
<input type="text" name="toolset_maps_distance_center" placeholder="Search Location">
<input type="hidden" name="toolset_maps_distance_radius" value="30">
<input type="hidden" name="toolset_maps_distance_unit" value="mi">
<input type="submit" name="wpv_filter_submit" value="u">
</form>

When I run an example search from my fields, the values are reflected in the Toolset filter fields, so there is communication between my fields, and the filter fields. So for example, I search "labrador" near "erie, pa", I get the appropriate URL parameters showing up in the address bar:

/?wpv_post_search=labrador&toolset_maps_distance_center=erie%2C+pa&toolset_maps_distance_radius=30&toolset_maps_distance_unit=mi&wpv_filter_submit=u

...which are near identical to filter fields

/?wpv_view_count=638&wpv_post_search=labrador&toolset_maps_distance_radius=30&toolset_maps_distance_unit=mi&toolset_maps_distance_center=erie%2C+pa&wpv_filter_submit=Submit

The only parameter I'm lacking is the wpv_view_count and the wpv_filter_submit value. That would matter if the Toolset fields functioned as I'd expect them to, but they're not. In this example, I have two posts associated with the "Labrador Retriever" term under the "Dog Categories" taxonomy. One is "located" in Harborcreek, PA, and the other is associated with Pittsburgh, PA. These two locations are approximately 128 miles apart, well outside my 30 mile radius limit. Both posts show up when I run my search as described above. Running an exact search for a "labrador retriever" near "harborcreek, pa" produces the same results.

As I stated, I was using GeoDirectory for location searching, but since it wasn't working, I have since disabled the Google Maps API for the plugin, to see if there was a conflict between GD's map API and Toolset's. Previously, in the inspector's console, it stated that I was using multiple Google Maps APIs, which could cause errors, and since disabling the API for GD, it now states, "Maps API Not Loaded :("

GeoDirectory's implementation is required, as now its purpose is to strictly provide a shopping cart for directory listing packages. It'll handle PayPal subscriptions for recurring payments, as well as cancelling and expiring packages. The post type "Dog" is a CPT made through GD, not Toolset, so if I disable GD, to troubleshoot, I also lose all my posts.

Regarding Relevanssi. For whatever reason, without it, I'm unable to get results, but I suspect it might be interfering. It's also highly likely that I have something configured incorrectly, but the goal was to focus search results on taxonomy terms of "Dog Categories" (dog breeds), versus the post title or body. The logic here is that the post title is going to be the dog's name, as it wouldn't make sense to name the post after the dog's breed, of which there will likely be many. No one is going to search for a dog's name, they're going to search for the dog's breed, which is needed as a filterable item anyway.

I'm sorry if this rather long winded, but I've been tossing this around for awhile, so I'm hoping I could get some assistance from you guys as I got everything into the Toolset world. By all accounts, it (hopefully) shouldn't matter what GD is doing, as all the information provided in the archives is populated by Toolset fields and taxonomies, with the exception of the "Dog Categories" taxonomy.

#868769

Unfortunately the distance filter is not functional on WordPress Archives. Sorry for the confusion here, in my opinion the distance filter should be removed as an option here if it doesn't work. Hopefully we will be able to address that very soon, followed by implementing a fully functional distance filter. The best alternative right now is to recreate the WordPress Archive as a View and apply the distance filter there. Remove all the contents from the wpv-loop tags in the WordPress Archive, and insert the View in the WordPress Archive Loop Output, somewhere outside the wpv-loop tags.

#868942

That's...inconvenient. Well, I suppose I have no other choice. At least I have an answer. Thanks for your help!

#869201

One more question: We still need the distance filtering for archives. If I put a view in a layout associated with a taxonomy archive, will it work just like the "Wordpress Archive" cell, but with the location searching features?

#869321

Not exactly, because a WordPress Archive cell automatically responds to the current archive page to show the correct results. You would have to apply Query Filters to the View to force it to show the same results you would find in a WordPress Archive cell. For example, if you put the View on a taxonomy archive, you must apply a taxonomy Query Filter to the View, filtered by term, where they term is set by the current archive, or by a shortcode attribute, or some other method of passing the archive term into the filter.

#869470

Gotcha. I was figuring as much, when I started moving things over.

So, I created a view and copied over the necessary elements to recreate the "Wordpress Archive" cell, and placed the view into the archive layout, and into a page titled "Test" found here: hidden link

Neither worked. In fact, I'm getting the same results as I was when I had it located in the archive cell.

#869583
Screen Shot 2018-05-09 at 2.53.19 PM.png

Okay thanks. I activated Views debug mode (Toolset > Settings > Frontend Content > Debug mode), and I'm attaching a screenshot of what I see here for you to review. It appears that one of the GeoDirectory plugins is overriding the query, and setting query to be for the "gd_place" post type. Obviously, that is not correct. Somewhere down the line this one post gets added, but I'm not quite clear where that is happening yet. Is it okay for me to turn off some plugins temporarily, or would you prefer to do that? I'd like to narrow down the source of the conflict.

#869586

Yes. Please go ahead and do what you need to do. Please note that I am using gd_place. My "Dog" CPT's slug is gd_place, and I intentionally configured this into the view/Wordpress Archive.

I also noticed that when I was scouring your ("your" as in Toolset's) documentation, to see if I've gone wrong somewhere, that it states that "To add a Distance filter, make sure that the Filter Editor section is enabled for your View or a WordPress Archive."

If it's something that has yet to implemented properly, as you've stated yourself, perhaps it shouldn't be in the documentation?

https://toolset.com/documentation/user-guides/display-on-google-maps/displaying-markers-on-google-maps/#filtering-markers-by-distance

I mean, at this point, though, I think the problem is deeper than merely using this filter in a WordPress Archive cell.

#870001

How did you create the Dog post type? When I deactivate everything but Types, the Dog post type disappears.

#870002

Sorry, I just reread your earlier post and you explained that already, stand by.

#870073

I just deleted and recreated the distance filter in this View and the results look more like what I would expect to see:
hidden link

Can you take a quick look?

#870152

Looks like location is working, but when coupled with text search, it doesn't seem to work. Should I recreate the text search, as well?

Edit: recreating the text search field did not work. Is it because the text search filter can't search for taxonomy terms?

#872615

Edit: recreating the text search field did not work. Is it because the text search filter can't search for taxonomy terms?
I see you are using Relevanssi. Relevanssi sorting often overrides Views sorting when a text search is involved, so I think the first test is to disable Relevanssi temporarily to see if that changes the results.

#872655

You currently have Relevanssi disabled.

I have a theory, please me know if my logic is flawed:

With Relevanssi disabled, the wpv_post_search filter parameter searches are strictly focused on post titles, body, and custom fields, but does not include taxonomy term relationships, so only the location field operates on its own. As a consequence of this, a search for "labrador" near "erie, pa" shows no results because the post titles, content, and custom fields do not have "labrador" in them. The dog's breed, which is what the expected search query is going to be, is strictly associated with the taxonomy term. This might explain why a location search without a text search shows location relevant results.

If this is the case, is there a way to programmatically make the wpv_post_search filter look for taxonomy terms? I honestly don't care about post title relevance, as the post title is associated with the dog's name, making it useless to me. There's also no way we can rely on the user to have the dog's breed contained within the post body, or other custom fields.

With Relevanssi enabled, I suspect that since it overrides much of what the default search mechanisms do, it removes Toolset's distance filter functionality, and focuses on the text search, which I have configured to look at the taxonomy terms as the priority. As far as I could tell, there were not any options in Relevanssi to allow for Toolset distance filtering.

#872755

I've enabled all other plugins, aside from Relevanssi, and it seems that my theory still holds true. I can search for location, and come up with location relevant results, however text search still comes up with nothing.