Skip Navigation

[Resolved] [wpv-control-post-relationship] and/or [wpv-control-post-ancestor]

This support ticket is created 2 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/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 2 years, 10 months ago.

Assisted by: Waqar.

Author
Posts
#2313579

HI. I am trying to setup filters (hidden link). I have 2 questions
1. QUESTION 1 :
I have eight filters. Every filters are working correctly except one (Type de capteur : the first of the second line).
This one is not reseting when I click on "Recommencer" and most of all is not filtering my products !!

Maybe the problem is related to the fact that I have two filters on the relationships ??? well I'am just saying this out of pure guessing

Here is the search and pagination config in Toolset views :
####################
[wpv-filter-start hide="false"]
[wpv-filter-controls]
<div class="filtre-dream">
[wpv-control-post-taxonomy taxonomy="product_parametre" type="select" default_label="Paramètre" url_param="wpv-product_parametre"]
</div>
<div class="filtre-dream">
[wpv-control-post-taxonomy taxonomy="product_mono-multi" type="select" default_label="Catégorie" url_param="wpv-product_mono-multi"]
</div>
<div class="filtre-dream">
[wpv-control-post-taxonomy taxonomy="product_principe-de-mesure" type="select" default_label="Principe de mesure" url_param="wpv-product_principe-de-mesure"]
</div>
<div class="filtre-dream">
[wpv-control-post-taxonomy taxonomy="product_type" type="select" default_label="Type de mesure" url_param="wpv-product_type"]
</div>
[wpv-control-post-relationship ancestors="generique@generique_product.parent" url_param="wpv-relationship-filter"]
<div class="filtre-dream generique">
[wpv-control-post-ancestor type="select" ancestor_type="generique@generique_product.parent" default_label="Type de capteur"]
</div>
[/wpv-control-post-relationship]
<div class="filtre-dream">
[wpv-control-postmeta type="select" field="wpcf-solution-iot" default_label="Solution IOT" url_param="wpv-wpcf-solution-iot"]
</div>
<div class="filtre-dream">
[wpv-control-postmeta type="select" field="wpcf-service-france" default_label="Service en France" url_param="wpv-wpcf-service-france"]
</div>
[wpv-control-post-relationship ancestors="societe@societe_product.parent" url_param="wpv-relation-fab"]
<div class="filtre-dream">
[wpv-control-post-ancestor type="select" ancestor_type="societe@societe_product.parent" default_label="Fabricant"]
</div>
[/wpv-control-post-relationship]

<div style=" margin-left: auto; margin-right: auto; width: fit-content;">
[wpv-filter-submit name="Sélectionner" output="bootstrap" class="et_pb_button" style="margin-right: 10px; background-color: #006FBF; color: white; font-size: 14px; font-weight: bold;"]
[wpv-filter-reset reset_label="Recommencer" output="bootstrap" class="et_pb_button" style="margin-left: 10px; background-color: white; color: #006FBF; font-size: 11px; font-weight: normal;"][/wpv-filter-controls]
</div>
<div style="margin: 15px">
[wpv-conditional if="('[wpv-search-term param='wpv_view_count']' ne '' )" ]
[wpv-pagination]
[wpv-pager-prev-page style="color: blue; text-decoration: underline"][wpml-string context="wpv-views"]Produits précédents[/wpml-string][/wpv-pager-prev-page]
[wpv-pager-next-page style="color: blue; text-decoration: underline"][wpml-string context="wpv-views"]Produits suivants[/wpml-string][/wpv-pager-next-page]
[/wpv-pagination]
[/wpv-conditional]
</div>
[wpv-filter-end]
######################

2. QUESTION 2 :
concerning the last filter (based on the relationship called "societe_product") : how can I filter the options listed? I'd like to filter them based on a field (adherant_dream) being equal to 0

thanks !!!!

#2313955

Hi,

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

1. Your understanding is correct and in views, you can use only one relationship filter. I'm afraid, you'll have to keep only one of them, as both won't work.

2. As there is no built-in feature or option available to filter the list of relationship field's options, this will require some workaround and code customization.

For example, you can include a custom 'select' field next to the actual relationship field and populate its options using the "get_posts" query with the relevant custom field filter ( ref: https://developer.wordpress.org/reference/functions/get_posts/ ).

Next, you'll need to include some custom script, that would select the same option in the actual relationship field when an option in this custom select field is selected. You can hide the actual relationships select field using some CSS code so that visitors can't interact with that field directly.

This way, when the search form will be submitted, the selected relationship field option will be used for the search.

I hope this helps and for more personalized assistance around custom code, you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/

regards,
Waqar