Skip Navigation

[Resolved] Conditional based on blank/not blank field not working

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/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by Waqar 1 year, 5 months ago.

Assisted by: Waqar.

Author
Posts
#2493791

Tell us what you are trying to do?
Hi, I'm trying to make it so this custom field doesn't appear if the custom field for that entry is blank (so it only appears if they have added content to that field), but I can't seem to get it working correctly.
Is there any documentation that you are following?
Based on other support tickets I've read through, I believed this would do it: [wpv-conditional if="( $(wpcf-related-news) ne '' )"], however it's not working.
Is there a similar example that we can see?

What is the link to your site?
Here is a post entry WITH content in the field (so "Related News" should appear below "Description+" in the right column: hidden link
Here is a post entry WITHOUT content in the field (where that area should remain blank): hidden link

#2494267

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

The conditional statement format that you shared seems correct and it should work.

To troubleshoot why this isn't working, I'll need to see how this field and the content template are set up in the admin area.

Can you please share temporary admin login details, in reply to this message?

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

regards,
Waqar

#2495823

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for sharing the admin access details.

During troubleshooting, I noticed that the view "Portfolio Related News Content" was set to show one result from the "Portfolio" post, with respect to the date.

But, actually, you need this view to show the same "Portfolio" post on which this view is being shown.

To achieve this, I followed these steps:

1. In that view's "Query Filter" settings, I added a post ID filter, so that it includes only posts with IDs set by the View shortcode attribute "ids".
( screenshot: hidden link )

2. Next, I removed the "Toolset Views" module from the "Portfolio Base Page Template" and called the same view using the shortcode, in a "Text" module:
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-view )


[wpv-view name="Portfolio Related News Content" ids="[wpv-post-id]"]

Please note how, I've used the shortcode "[wpv-post-id]" in the view's shortcode attribute "ids", so that view only shows the current portfolio post.

After these changes, the conditional statement inside the view is working, as expected.

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