Skip Navigation

[Resolved] Listings w/ Multiple Addresses (Repeatable Field Group) and Search

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

Last updated by Christian Cox 5 years, 1 month ago.

Assisted by: Christian Cox.

Author
Posts
#1368023
clinic search listing.png

**Tell us what you are trying to do?**

I am creating a directory listing of clinics. A few have multiple locations. I first set up the clinic address as a repeatable field, but then changed it to a repeatable group that has a field for clinic address and phone number.

I want the search to be based on zipcode/location (I will want to list clinics globally, so I wanted to avoid making Taxonomies for city/state(region)/country) and have it filter solely based on zipcodes. I think I set something up wrong. Because I have a few different problems happening.

1) not all the addresses are showing up. One listing I have had entered 5 addresses, they are not displaying. (The listing I created for "Anew Era TMS" isn't showing any addresses. and if I search "Huntington beach CA" I should see a few different listings, but I only see one. I think I set something up incorrectly in my view: Clinics - Search Form. What I want to happen is someone types in their city, edits the search radius and a list of nearby clinics displays. ... but maybe I need to set up the repeatable group differently?

2) as soon as you use the filter something strange happens to the content template (weird BG image issue) - I am not sure if this is a content template bug or what. (see attached image)

**Is there any documentation that you are following?**

I have both the classified and real estate reference site.
I also found this post, but I am not understanding: https://toolset.com/forums/topic/posts-with-multiple-addresses-show-closest-address-location-from-view-search/

Is there a similar example that we can see?

What is the link to your site?
findtmstherapy.com/search-clinic-listings/

#1368049

Hi,
Can you take screenshots of this View editor screen in wp-admin so I can see your configurations?

In general, it's not currently possible to filter a View of some post type using address fields in one of its repeatable field groups. Instead, you would have to create a View of the RFG. It sounds like you need to create a View of the RFG and add a distance filter based on the custom address field. A post relationship filter is not required here. Then in the results, you could display information from the parent post using the Post Selection tab in the Fields and Views popup, or information from the corresponding RFG item like the address and phone number.

#1368087
RFG View.png
screencapture-findtmstherapy-co-wp-admin-admin-php-2019-10-23-14_59_40.png
screencapture-findtmstherapy-co-wp-admin-admin-php-2019-10-23-15_00_17.png
ContentTemplate_LoopItemClinic.png

Ok... I tried RFG View and it is displaying addresses that are unrelated to the parent

#1368125

A few things:
- The search View Content Selection should only include the Clinic Info RFG post type. It should NOT include the Clinic Listings post type.
- There should be no location-info View in the Content Template for Loop Item in Clinics Search Form. That View should be removed from the Content Template. Then the Search View should show all the addresses within the radius of the search. The parent is irrelevant at this point, because the View simply shows addresses within the search radius.
- If you want to display information about the parent Clinic Listing for each address, use the Fields and Views button in the Content Template to choose the post title or whatever you want to display, and use the Post Selection tab in that popup to choose the parent Clinic Listing post.

#1368271
screencapture-findtmstherapy-co-2019-10-23-18_23_27.png

Ok thanks, that gets me closer... But when I have multiple addresses (like the last listing on this screenshot) it is not showing up

#1368307
screencapture-findtmstherapy-co-clinic-anew-era-tms-2019-10-23-18_40_36.png

Similarily... I have the map/marker working on my clinic profile pages that have 1 location ... but it is not working on the clinic that has multiple locations

New threads created by Christian Cox and linked to this one are listed below:

https://toolset.com/forums/topic/listings-w-multiple-addresses-not-appearing-on-map-view/

#1369171

Ok thanks, that gets me closer... But when I have multiple addresses (like the last listing on this screenshot) it is not showing up
- Are all of the multiple addresses for the last listing within the 10 mile radius?
- Do you want to display all addresses for a clinic if any of the addresses are within the 10 mile radius? Or do you only want to display addresses that are within the 10 mile radius?

Similarily... I have the map/marker working on my clinic profile pages that have 1 location ... but it is not working on the clinic that has multiple locations
I'll split this off into another ticket so we can keep this ticket focused on the search page.

#1369185

When I run the search - I want to see only the clinics in the search radius ...

But in the screenshot above I have not entered anything (city or zip) into the search yet.

#1369499

Okay this is a View of Clinic Listings, so you would have to insert a View of the Clinic Info RFG to show multiple addresses in each result.

HOWEVER

The distance filter will not work in a View of Clinic Listings, because the address fields are in the Clinic Info RFG. It is not possible to filter a View of Clinic Listings by a field in the Clinic Info RFG. That's what I was trying to explain here: https://toolset.com/forums/topic/listings-w-multiple-addresses-repeatable-field-group-and-search/#post-1368125

You must create a View of Clinic Info RFG if the address field is in the RFG. Otherwise, the distance filter will not work correctly, and will not consider more than one address for each Clinic Listing. This could cause problems. For example, let's say Clinic 1 has 4 addresses. When you search by distance filter, 2 of the addresses for Clinic 1 are found within the search distance radius. So those 2 addresses will appear as separate results. This means you have duplicate Clinic 1 results like this:
- Clinic 1: Address 1
- Clinic 1: Address 2
- Clinic 2: Address 1
- Clinic 3: Address 1
...etc...
Sometimes that is okay, but sometimes you want to show a different grouping. It is very difficult to get results organized like this:
- Clinic 1: Address 1, Address 2
- Clinic 2: Address 1
- Clinic 3: Address 1
...etc...
It would require a significant amount of custom code to get this right, because of a limitation in Views: you cannot filter a View of posts by fields in its repeatable field groups. I hope this helps clarify the situation and your options for using a distance filter in a View.

#1370087

Oh... should I not have multiple locations as a RFG? I could just have it as a repeatable field instead? I was trying to figure out how to handle that - some of the clinics have a unique number for each address, some have one main number for each address ... or perhaps I only allow 1 address per listing and force users to create multiple listings if they have multiple addresses?

What would you recommend?

#1371017

Oh... should I not have multiple locations as a RFG? I could just have it as a repeatable field instead?
If you want to use a distance filter, or include a phone number for each individual location, RFG is a better option than a single repeating address field. A single repeating address field won't work with a distance filter, and you can't associate a phone number with one item in a single repeating address field.

...or perhaps I only allow 1 address per listing and force users to create multiple listings if they have multiple addresses?
This is another possibility, but it could lead to having duplicate information in listings. It really depends on what works best for your site. If you'd like to see how all the pieces fit together, we offer a free Toolbox sandbox site at https://discover-wp.com. We can collaborate, set up test scenarios, and test different setups on the backend. It's free to use this site. If you sign up using the email from your Toolset.com account, I can add you to a test project.