Hello,
I have build this
[wpv-conditional if="( has_term('auteurs', null) ne '0' )"]<p class="auteurs">Auteurs : [wpv-post-taxonomy type="auteur"]</p>[/wpv-conditional]
in order to display content only if the taxonomy "auteurs" is not empty.
But it doesn't seem to work, and always return nothing, as if it was always empty (which it's not).
I have added the has_term function to toolset settings in conditional section with no result.
Thank you.
Hello and thank you for contacting the Toolset support.
I believe that you are not using has_term the correct way, you need to pass the term to the function instead of the taxonomy. Check the function documentation https://developer.wordpress.org/reference/functions/has_term/
I suggest using:
[wpv-conditional if="( '[wpv-post-taxonomy type='auteurs']' ne '' )"]<p class="auteurs">Auteurs : [wpv-post-taxonomy type="auteur"]</p>[/wpv-conditional]
I am not sure what is the slug of your taxonomy ('auteurs' or 'auteur'), edit the code to have [wpv-post-taxonomy type="taxonomy-slug"]
I hope this helps. Let me know if you have any questions.
Well I'm sorry but I still can't make this work.
My taxonomy slug is "auteur".
Here is what I got on a single post template :
[wpv-conditional if="( '[wpv-post-taxonomy type='auteur']' ne '' )"]<p class="auteurs">Auteurs : [wpv-post-taxonomy type="auteur"]</p>[/wpv-conditional]
[wpv-conditional if="( '[wpv-post-taxonomy type='auteur']' eq '' )"]Pas d'auteur associé à cet article.[/wpv-conditional]
On both pages with terms and pages without terms, nothing is displayed.
Please allow me temporary access to your admin area to check this further. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **
I added format='slug' to the shortcode and it fixed the issue.
[wpv-post-taxonomy type='auteur' format='slug']
https://toolset.com/documentation/user-guides/views/views-shortcodes/#vf-153472
Sorry for not suggesting that in my previous reply.
Thank you very much ; works like a charm.
My issue is resolved now. Thank you!