Home › Toolset Professional Support › [Resolved] How to use conditionals to hide an element when a post does not have a taxonomy
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/Hong_Kong (GMT+08:00)
Tagged: Views, Views plugin
This topic contains 2 replies, has 2 voices.
Last updated by AtefR7377 4 years, 12 months ago.
Assisted by: Luo Yang.
Hi,
I have a CPT called "Books". it has a custom taxonomy called "Publisher".
I am creating a table to show some information about the books, and want the whole table row to not show when the book does not have a publisher (i.e. when there is no publisher taxonomy term associated with this post)
I used the conditional below, but it did not work. it still showed me the table row, with the word "Publisher:" in one cell, and an empty cell next to it.
[wpv-conditional if="( NOT(CONTAINS(#(publisher),'')) )"] <tr> <td class="text-nowrap">Publisher: </td> <td>[wpv-post-taxonomy type="publisher"]</td> </tr> [/wpv-conditional]
I use the same concept to test for some other data in the post and hide some rows when their associated custom fields are empty.
can you please advise a solution?
thanks
Hello,
You can try below shortcodes:
[wpv-conditional if="('[wpv-post-taxonomy type='publisher' format='slug' ]' ne '' )"] There is a term assigned to current post.... [/wpv-conditional]
More help:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/displaying-taxonomies-conditionally/#one
Checking if a post has at least one term assigned
Hi,
Yes the code you provided works. I had found it on an old view that I created. however, when I use the current plugin graphical user interface, I get the strange code I posted in the original question.
Thanks.