I'm trying to list associated taxonomy terms under posts in a view using the following code, and NOT display the word "Tags:" if there are none. The code that I'm trying to use (below) is not working; it will always come back as TRUE even if nothing is assigned to a post in those taxonomies. Is there another way I should be checking?
This doesn't work, but perhaps I just wasn't clear in my question. has_term seems to check for specific taxonomy terms. I need to see if any terms were applied at all (from the multiple taxonomies - school_subject,identity_markers,issue_areas.
So displaying them with : [wpv-post-taxonomy type="school_subject,identity_markers,issue_areas" format="text"]
works fine, but I want to somehow test to see if that would yield an empty result, and if so not display the "Tags:" text.
I tried testing for ([wpv-post-taxonomy type="school_subject,identity_markers,issue_areas" format="text"] ne '' ) but cound't get that to work. Perhaps my formatting was off?
Can you enable the debug on the conditional shortcode by adding debug="true" ?
Also you can combine the conditional shortcode to check across multiple taxonomies.
[wpv-conditional if="('has_term('','school_subject')' ne '1' ) OR ('has_term('','identity_markers')' ne '1') OR ('has_term('','issue_areas')' ne '1') "]
<p>Tags: [wpv-post-taxonomy type="school_subject,identity_markers,issue_areas" format="text"]</p>
[/wpv-conditional]
That doesn't work. But again, isn't that the incorrect use of has_term, as I am checking for anything with a custom taxonomy, not a specific term?
I went back to this:
[wpv-conditional debug="true" if="('[wpv-post-taxonomy type='school_subject,identity_markers,issue_areas' format='text']' ne '' )"]
<p>Tags: [wpv-post-taxonomy type="school_subject,identity_markers,issue_areas" format="text"]</p>
[/wpv-conditional]
And get the below in the debug for an entry with no terms set in and of those custom taxonomies:
####################
Debug information
####################
--------------------
Original expression: ('' ne '' )
--------------------
After replacing 1 general variables and comparing strings: ('' ne '' )
Comparing to
####################
Debug information
####################
--------------------
Original expression: ('Woman' ne '' )
--------------------
After replacing 1 general variables and comparing strings: ('Woman' ne '' )
Comparing Woman to
So I want to be able to display the "Terms:" text only when terms are set.