Hi!
I have a view with a parametric search for "evento-corso" post type
evento corso is child of crystal-nails-corsi
I'd like to filter by a field "livello" id="$crystal-nails-corsi"
I've tried this but it doesn't work
[wpv-control field="livello" id="$crystal-nails-corsi" url_param="livello" type="select" auto_fill_default="cerca" auto_fill="wpcf-livello" auto_fill_sort="asc"]
The result is no item found
At the same time in the Output template of this view I can see correctly
Livello:[types field="livello" id="$crystal-nails-corsi"][/types]
Can you help me?
Thank you! Alba 🙂
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
As I understand you want to filter your post by specific parent custom field [types field="livello" id="$crystal-nails-corsi"][/types].
You can pass argument of your parent field to child view and filter the child view with views shortcode argument. :
For example:
[wpv-view name="Child view - listing training posts" child_of="[wpv-post-id]"]
More Info
=> https://toolset.com/documentation/user-guides/passing-arguments-to-views/
=> https://toolset.com/documentation/user-guides/using-a-child-view-in-a-taxonomy-view-layout/
=> https://toolset.com/documentation/user-guides/filtering-views-by-custom-fields/
This related tickets may help you:
https://toolset.com/forums/topic/how-filter-child-post-by-parent-field/
https://toolset.com/forums/topic/how-to-filter-childs-post-depending-on-a-parent-field-value/
If your issue still persist, please do not hesitate to get in touch with me with a test example about your current CPT setup.
Hi! 🙂
Can you write me the exat way to insert that shortcode in my code?
- This view is for evento-corso
- that is child of crystal-nails-corsi
- LIVELLO is a field of crystal-nails-corsi
[wpv-filter-controls]
[wpml-string context="wpv-views"]<label>Difficoltà:</label>[/wpml-string][wpv-control field="livello" url_param="livello" type="select" auto_fill_default="cerca" auto_fill="LIVELLO" auto_fill_sort="asc"]
[wpv-filter-submit name="Cerca il tuo Corso" type="input"]
[wpv-filter-reset reset_label="Azzera la ricerca" type="input"]
[/wpv-filter-controls]
Thank you so much!
Alba
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Sorry but I'm bit confuse here - could you please explain me what exactly you want to display and what are the filters you want to have - a dummy test case will be helpful to understand your requirement.
Ok i'll try to explain better 🙂
For example:
I have a custom post type "Events" that is child of "courses" and "locations"
courses+locations+date (the only field that belongs to Events) =events
I have a view with a parametric search that is applied to "Events"
I'd like to filter by the field "province" that belongs to "locations"
I don't know how to write in the search that "province" belongs to "locations"
i'd like to have as result the list of all the events for the selected province
Thanks!! 🙂
Alba
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
You need to create parent/child views.
1)
- Create a view "Events-child"
- "Content Selection" section select CPT "Events"
- "Query Filter" section add:
Post relationship filter
Select posts that are a children of the Post set by parent View.
- Loop output section, add post link, for example:
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop>
[wpv-post-link]
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-layout-end]
- save your view
2)
- Create a view "locations-parent"
- "Content Selection" section select CPT "Location"
- "Filter" section add field "province", for example
[wpml-string context="wpv-views"]province:[/wpml-string] [wpv-control field="province" url_param="province" type="select" auto_fill_default="Please select" auto_fill="wpcf-province" auto_fill_sort="asc"]
- Loop output section, add child view "Events-child", for example:
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<ul class="wpv-loop js-wpv-loop">
<wpv-loop>
[wpv-view name="child-view-pr-events"]
</wpv-loop>
</ul>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
[/wpv-no-items-found]
[wpv-layout-end]
-save your view
3)
Add your parent view "locations-parent" to your page and you will have results you are looking for.
Please refer to the following links that may help you:
=> https://toolset.com/documentation/user-guides/using-a-child-view-in-a-taxonomy-view-layout/
=> https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/
=> https://toolset.com/documentation/user-guides/passing-arguments-to-views/