Skip Navigation

[Resolved] Filter results from a repeater field

This support ticket is created 5 years, 9 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
- 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: Asia/Karachi (GMT+05:00)

This topic contains 7 replies, has 2 voices.

Last updated by Louis-Philippe 5 years, 9 months ago.

Assisted by: Waqar.

Author
Posts
#1201307

//// Tell us what you are trying to do?
I built a location map that will display the shop that are selling my products.
For this, I create a CPT but I get the address and all custom fields from a repeater field.
I this repeater, I have a checkbox that contains 3 types of products named "available-products"
I want to be able to filter the loop results with 3 buttons that are related to the checkbox field.

/// Is there any documentation that you are following?
For sure, I read all the doc about filter!

///Is there a similar example that we can see?

/// What is the link to your site?
hidden link
The sample is on top as a graphic only, the view that I started is under the first map.

Thank you for your help.

#1201554

Hi Louis,

Thank you for contacting us and I'll be happy to assist.

Based on what you've shared, I understand that you have a CPT "Shop", and each shop can have multiple locations and you're using a repeatable field group, to store information about each shop's location.

If that is correct, it won't be possible to filter the view that shows the list of shops, based on a checkbox or any other type of custom field, that is part of a repeating field group. This is because, the way repeating field group field's data is saved, it is stored as a separate child posts and not with the actual parent post (which in your case is "Shop" CPT).

To make this work, you can create a new CPT "Shop Locations" and store each shop's location information, as an individual post in it. The custom fields for location and type of products offered will also be saved with this new CPT.

Next, you can create a "One-to-Many" relationship between "Shop" and "Shop Locations" CPT:
https://toolset.com/documentation/post-relationships/

This will allow you to create a view of "Shop Locations" and show the results on the map, with the filters based on the type of product it offers.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1201755

Thank you Waqar. But if I create a new CPT (shop locations), will it not be easier to use categories for my type of products to filter and still display on a map instead of wanting a One-to-Many relationship ?

Or maybe the product type are a CPT and a Shop locations too so I can make them in one-to-many relationship ?

I really appreciate you help on this topic!

#1202011

Actually, I set up both and they work well, next level now.
Can I change the name of the filter terms at all ? If I want to add some extra juicy subtitle and make them as button ?
My idea is to use some custom field to insert into the terms. Thank you.

hidden link

#1202149

Hi Louis,

Thanks for writing back.

I've checked the page and noticed that the search filter is now working with a custom title and buttons.
( screenshot: hidden link )

Looks like you've managed to make this work, after writing to us.

Please let me know if you need any further assistance around this and for a new question/concern, please open a new ticket.

regards,
Waqar

#1202564

Well, I use CSS ::before to make it happen, not a client easy change to make.
I would still like to know if I can use meta terms custom field to spice up the text of category please.
Also my other concern is the reset button.

As you see, my filter is on top of the map, and I want the reset to be positioned below the map...
Maybe it's just easier than I can think.
Thank for all your awnsers and dedication!

Lp (*

#1203207

Hi Louis,

When the "wpv-control-post-taxonomy" shortcode is used in the "Search and Pagination" section, it generates the list of taxonomy terms automatically. That output can be customized using the available attributes, as listed at:
https://toolset.com/documentation/user-guides/views-shortcodes/#vf-521572

In case you'd like to generate this list manually in an even more customized format, you can copy the output that shortcode generates, customize it and replace it with the "wpv-control-post-taxonomy" shortcode.

For example, currently the output for the taxonomy filter is:


<div class="filter-button">
	<div class="radio">
		<label for="produits-offerts-detaillants" class="classe etiquette">
			<input type="radio" id="produits-offerts-detaillants" class="js-wpv-filter-trigger" name="wpv-produits-offerts" value="detaillants">
			Détaillants
			<i class="fa fa-arrow-down--"></i>
			<span class="soustitre"></span>
		</label>
	</div>
	<div class="radio">
		<label for="produits-offerts-tribe-en-fut" class="classe etiquette">
			<input type="radio" id="produits-offerts-tribe-en-fut" class="js-wpv-filter-trigger" name="wpv-produits-offerts" value="tribe-en-fut" checked="checked">
			Tribe en fût
			<i class="fa fa-arrow-down--"></i>
			<span class="soustitre"></span>
		</label>
	</div>
	<div class="radio">
		<label for="produits-offerts-remplissage" class="classe etiquette">
			<input type="radio" id="produits-offerts-remplissage" class="js-wpv-filter-trigger" name="wpv-produits-offerts" value="remplissage">
			Remplissage
			<i class="fa fa-arrow-down--"></i>
			<span class="soustitre"></span>
		</label>
	</div>
</div>

As long as the values in the "name" and "value" attribute remain the same, in your custom HTML code, it should work.

Note: in that custom HTML, you can also call in data from the term meta, using "Types Fields API":
https://toolset.com/documentation/customizing-sites-using-php/functions/

To make sure that the reset button works correctly, it needs to be present in the "Search and Pagination" section. So if you'd like to show the map before this button, you can move the map's shortcode "[wpv-map-render]", in this "Search and Pagination" section, above the reset button.

For future reference, please note that as per our support policy ( https://toolset.com/toolset-support-policy/ ), only one question or issue can be addressed through a single ticket.

You're welcome to open a new ticket for each new question or concern.

regards,
Waqar

#1203464

My issue is mostly resolved now. Thank you!
I have enough knowledge now to complete it.
Also sorry for not following the rules, I did not know!