Hi there.
I have a custom post type called wine. This custom post type has different terms
Tipus de vins: blanco, rosado, negro...
Llocs de consumicio: restaurant, domicili (in place or delivery)
I have a post view [wpv-view name="vista-de-vins-a-domicili"] that shows all posts filtered by:
Select posts with taxonomy: Tipus de vins set by the parent Taxonomy View AND Llocs de consumicio in all of these: Domicili
Taxonomy view that display tipus de vins [vista-de-tipus-de-vins-a-domicili], and are checked
Don't show empty terms
Include terms that have non-empty descendants
Include children in the post count
Loop item in Vista de tipus de vins a domicili -> I have
<h3>[wpv-taxonomy-title]</h3>
[wpv-view name="vista-de-vins-a-domicili"]
The problem is -> this view is showing terms with empty posts
I have wine rosé... but not all rose have the term "a domicili". In this case the view has no records, but if it have no records the term... why does it show in the view
This is the url where you can see the unexpected results of the view: hidden link
Thanks in advanced
Hello,
I have checked the URL you mentioned above:
hidden link
There are two terms show result: "No items found":
- Vi Rosat
- Cava
How do you setup above two terms?
Are there sub-term under above two terms?
Are these two terms assigned with posts of other post types?
If there are sub terms under them, then you can edit the parent taxonomy view, disable option "Include terms that have non-empty descendants".
If these two terms are assinged with posts of other post types, then it is expected result, the condition "Don't show empty terms" is satisfied.
Hi Luo and thanks you time. I answer below:
Are there sub-term under above two terms? No
Are these two terms assigned with posts of other post types?No... but llocs de consumicio YES. However... if i assign llocs de consumicio only to Vins... the result is the same
If there are sub terms under them, then you can edit the parent taxonomy view, disable option "Include terms that have non-empty descendants".There aren't subterms
If these two terms are assinged with posts of other post types, then it is expected result, the condition "Don't show empty terms" is satisfied. This terms aren't assigned with posts of other types. However... llocs de comsumicio is assigned to other 2 types of posts. If unassign this term to the other types of post the result is the same.
I attach 2 scrrenshots with the setup of my views.
Any idea?
Thanks again for your help.
Thanks for the details, please check the screenshot you provided above:
https://toolset.com/wp-content/uploads/2020/04/1602239-Captura_de_pantalla_2020_04_27_a_las_8.58.19.png
There is another taxonomy filter:
Llocs de consumicio in all of these: Domicili
Have you tried to remove it and test again? It might conduct the problem you menitioned above, since the parent taxonomy view does not know the child posts are satisfied above taxonomy filter.
In my opinion, what you need is:
Hide the term items when their child posts view are empty.
If it is, you can try these:
1) Edit the parent taxonomy view, in section "Loop Editor", find and edit child post view's shortcode: [wpv-view name="vista-de-vins-a-domicili"]
pass term's title as shortcode attribute, for example:
[wpv-view name="vista-de-vins-a-domicili" term_title='[wpv-taxonomy-title]']
2) Edit the child post view "vista-de-vins-a-domicili", just after shortcode [wpv-items-found], display the term's title with shortcode:
[wpv-attribute name="term_title"]
More help:
https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-attribute
This shortcode displays the value of an attribute in a View shortcode.
Hi again Luo.
Your suggestion works but not perfect. The title of empty taxonomies are not shown... but the message "no items found" is there. I don't know if a did all right.
Must I uncheck anything? Or just to delete the message in the output loop editor?
Yes, you are right, you can just delete the message in the output loop editor.
My issue is resolved now. Thank you!