Skip Navigation

[Resolved] How to check for empty taxonomy customer termmeta field

This support ticket is created 7 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: Africa/Cairo (GMT+02:00)

This topic contains 7 replies, has 4 voices.

Last updated by Thomas AMX 7 years, 6 months ago.

Assisted by: Ahmed Hussein.

Author
Posts
#398880

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

#399089

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!

#399281

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.

#399495

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!

#399853

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.

#401260

Thanks.

#688234

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!

#1154090

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

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.