Hello,
CPTs: "Centers" and "Units" with a many to many relationship
Custom Taxonomy: "Specialty"
"Specialty" is a taxonomy for both "Centers" and "Units".
Some Centers have Units, but others don´t.
This is part of the template for "Center":
Center A
Specialty 1
-- Unit 1
-- Unit 2
-- Unit 3
Specialty 2
-- Unit 4
-- Unit 5
Specialty 3
--Unit 6
This part´s output is shown through this view ("Specialties in a Center"):
<wpv-loop>
[wpv-post-body view_template="loop-item-in-specialties-in-a-center"] <!-- Shows the Specialty -->
[wpv-view name="units-in-a-hospital-per-specialty"] <!-- Shows the Units that have that Specialty-->
</wpv-loop>
It filters by taxonomy term defined by the current post.
The view loops the specialties of the Center, and then the Units that belong to each specialty.
If there is a Hospital that has no Units, then its specialties are shown with nothing below.
What I want is to show this area only for Centers that have Units. If there are no Units, the Specialty should not be shown.
Is there a way to set that condition?
Thank you.
Hi Roberto,
Thank you for getting in touch.
Unfortunately no there isn't a way to do this. The main issue here is because we are not able to evaluate a view in a conditional tag in order to display a specific text.
Perhaps this can be done using some amount of custom code but defaultly it isn't possible to do.
Thanks,
Shane
Just to add that I overcame this by adding a checkbox field to the Centers CPT named "Has Units".
Then I can use a conditional like "if Has Units is checked, show this".
It´s not the ideal solution but it works.
Hi Roberto,
Thank you for sharing the update.
Happy that you were able to resolve the issue. If there are any further issues I will be more than happy to assist. If not then you can go ahead and closed here.
Thanks,
Shane
My issue is resolved now. Thank you!