Skip Navigation

[Resolved] Non-Types field distance filter

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

Problem: I would like to use a hidden field managed by a 3rd-party system as the origin of a distance filter in my View.

Solution: Views distance filters are designed to work with Types Address fields only, so hidden fields from other plugins are not supported.

This support ticket is created 5 years, 4 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 6 replies, has 2 voices.

Last updated by umbertoZ 5 years, 4 months ago.

Assisted by: Christian Cox.

Author
Posts
#1164727

Hi, I've another issue with the Map location filter. I want to add a distance filter, but it doesn't get the YITH non-Types field _direction_event, even if it is alredy managed by Types. How can I do it?

thanks

#1164921

What is stored in the _direction_event custom field? Is it an address that is capable of being geocoded, or perhaps a pair of latitude and longitude coordinates?

#1164938

It is an address. There are also two fields that store long and lat.

#1165040

Please go to Toolset > Custom Fields and scroll down. Click "Post Field Control" and find the _direction_event field. Is the field type Address?

#1165064

_direction_event is not there, I can't see it on "Post Field Control" even if I selected it on "Hidden custom fields" and I can manage it in my view.

#1165576

That means it's a hidden field, not managed with Types. Though you can access its value in the Views GUI, you can only use "address" type fields managed with Types in a distance filter. So you could try setting up some custom code that copies values from the hidden field into a duplicate Types address field using the save_post hook, get_post_meta and update_post_meta, but there's no guarantee these values will be geocoded correctly. Normally Users would select a value from the autosuggest input field to geocode an Address, and I'm not sure how the values are captured by the other plugin.
https://codex.wordpress.org/Plugin_API/Action_Reference/save_post
https://codex.wordpress.org/Function_Reference/get_post_meta
https://codex.wordpress.org/Function_Reference/update_post_meta

#1169638

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.