Is there a way to check if a custom term meta field is empty or not? For example, I have a custom meta WYSIWYG field defined for a custom taxonomy and want to check if the field is empty or not.
this:
[wpv-conditional if="(NOT (empty('[types termmeta="cust-termmeta-summary"][/types]')) )"]
or
[wpv-conditional if="( '[types termmeta='cust-termmeta-summary'][/types]' ne '' )" ]
does not work
Hi, Thanks for contacting Toolset support forums.
Can you please add the debug attribute to the second condition and provide me with the debug information?
You can add the attribute as follows:
[wpv-conditional if="( '[types termmeta='cust-termmeta-summary'][/types]' ne '' )" debug="true" ]
Cheers!
I tried it and this is what I observed:
(1) empty field:
If the field is empty, this IF statement works. This is the debug output:
####################
wpv-conditional attributes
####################
Array
(
[if] => ( '' ne '' )
[debug] => true
)
####################
Debug information
####################
--------------------
Original expression: ( '' ne '' )
--------------------
After replacing 1 general variables and comparing strings: ( '' ne '' )
Comparing to
(2) non-empty WYSIWYG field with just plain text. Works. This is the output:
####################
wpv-conditional attributes
####################
Array
(
[if] => ( 'Use this guide to fix your bathroom.' ne '' )
[debug] => true
)
####################
Debug information
####################
--------------------
Original expression: ( 'Use this guide to renovate your bathroom.' ne '' )
--------------------
After replacing 1 general variables and comparing strings: ( 'Use this guide to renovate your bathroom.' ne '' )
Comparing Use this guide to renovate your bathroom. to
(3) non-empty WYSIWYG field with marked up text:
Looks like the IF statement does not quite compute, as there is NO debug output, as if the entire statement is skipped.
Hi, Thanks for your detailed reply.
I found that this is a known issue with our plugin, I reached to one of our 2nd tier supporters, and will let you know their feedback.
Cheers!
Hi, Thanks for your patience.
Unfortunately, conditional output for fields containing HTML tags isn't going to work due to some restrictions in the WordPress core. And there are no workarounds for this problem yet.
However, if any updates are done on this part of the plugin allowing to apply conditions on HTML fields I'll update you on this thread.
Thanks.
Hello Everyone,
I just wanted to report the same issue but with URL fields, I had to switch it to a single line field in order for the conditional to work.
Thanks!
Hi Everybody,
I had the same issue but with termmeta of image type. I've been looking for a solution and experimented. I have just discovered that adding output='raw' may be a solution. At least, it seems to work in my case (image field). Tested only on two taxonomy terms with image fields so far.
In case somebody finds this thread as I found it looking for a solution:
[wpv-conditional if="( '[types termmeta='taxonomy-image-1' output='raw'][/types]' ne '')"]
Cheers,
Tom