Skip Navigation

[Closed] how to use if empty condition within the HTML shortcode ?

This support ticket is created 3 years, 10 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 7 replies, has 2 voices.

Last updated by Minesh 3 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#2340989

Hi,
How do I display alternative text when the custom field is empty in a shortcode?
For example, I want to use the text "No date has been set" when the event date is empty?

DATE: [types field="event-date"][/types] | ADRESS: [types field="event-location"][/types]

#2341019

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

You can use the [wpv-conditional] shortcode to display conditional content.

Here is the Doc you should follow to check empty/non-empty values with example:
=> https://toolset.com/documentation/legacy-features/views-plugin/checking-fields-and-other-elements-for-emptynon-empty-values/

#2341207

ok, So if I understand, I do it like this?

[wpv-conditional if="( empty($(wpcf-event-date)) )"]
No date has been set[/wpv-conditional]
DATE: [types field="event-date"][/types] | ADRESS: [types field="event-location"][/types]

#2341211

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

It should be like this:

[wpv-conditional if="( empty($(wpcf-event-date)) )"]
DATE:  No date has been set
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-event-date) ne  '')"]
DATE: [types field="event-date"][/types] 
[/wpv-conditional]
| ADRESS: [types field="event-location"][/types]

One condition is for empty and one condition is for not empty.

#2341213

My issue is resolved now. Thank you!

#2341215

its not working

#2341217

its not working ;(

#2341219

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please share problem URL where the date is setup and not setup and admin access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

The topic ‘[Closed] how to use if empty condition within the HTML shortcode ?’ is closed to new replies.