Skip Navigation

[Resolved] Filtering with repeating fields

This support ticket is created 3 years, 10 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/Hong_Kong (GMT+08:00)

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 3 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#2018871

Tell us what you are trying to do?
Hello, I have a wpv-view that I'm using on multiple pages. Throughout my site have a CPT called home plans (properties) with a taxonomy of community. On this view I have properties show based on the current page archive. So If I'm on a certain community, the only properties that will be pulled are the ones in that community. These properties also have a pricing field that changes based on their community. So I have a repeater field that handles this. The repeater values are a tax object and a text field (to list the price). I need to be able filter a repeatable field inside a select box. So pretty much this. Grab Properties in archived community -> grab that property's pricing repeater -> loop through and compare the tax object with the current archive name. If they match print out the pricing value in that row into the select box. I have already done something similar with this shortcode I created.

// Pull Each Price Per Community
add_shortcode('ts_com_price', 'ts_com_price_func');
function ts_com_price_func( $atts, $content) {
$cont = do_shortcode($content);
$obj = get_queried_object();

if(have_rows('price_per_community')) :
while(have_rows('price_per_community')) : the_row();

$com = get_sub_field('community');
if($com->name == $obj->name) :
$price = get_sub_field('price');
endif;

endwhile;
endif;
// var_dump($price);
return $price;
}

Is there a way I could take that $price field and call it into the wpv-postmeta?

Like this:

<div class="form-group">
<!-- <label for="wpv-starting_price">[wpml-string context="wpv-views"]starting_price[/wpml-string]</label> -->
[wpv-control-postmeta field="$price" default_label="Price" type="select" url_param="wpv-wpcf-ts-com-price"]
</div>

or instead of field use the display_values?

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?
hidden link

#2019213

Hello,

Are we talking about a custom repeating field "Price" or a repeatable field groups?
https://toolset.com/course-lesson/creating-and-displaying-repeatable-field-groups/

In your case, in order to achieve this:
These properties also have a pricing field that changes based on their community

It needs to setup connection between "Price" field and "community" taxonomy, so you might consider to setup a child post type, for example: add a custom post type "properties price", setup one-to-many relationship between "properties" and "properties price", in the child post type ""properties price", setup:
- a custom field "price"
- taxonomy "community"

So in the single "property" post, you can setup a post view:
- Query child "properties price" posts
- Filter by:
a) the post type relationship between post types ""properties" and "properties price"
https://toolset.com/course-lesson/displaying-related-posts/#displaying-many-related-items
b) Select posts with taxonomy:
"community" the same as the current archive page
https://toolset.com/documentation/user-guides/views/filtering-views-by-taxonomy/
- In view's loop, display the "Price" field value