Skip Navigation

[Resolved] Hide field if empty

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.

This thread is resolved. Here is a description of the problem and solution.

Problem:
Want to hide some fields and headings in the Archive View if they are empty. The field in the conditional output is a term field.

Solution:
Solution with code here:
https://toolset.com/forums/topic/hide-field-if-empty/#post-575697

Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-shortcodes-in-conditions/

This support ticket is created 6 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Tagged: 

This topic contains 8 replies, has 2 voices.

Last updated by JorgeE7101 6 years, 6 months ago.

Assisted by: Noman.

Author
Posts
#575294

Hello. I'd like to hide some fields and headings if they are empty, but I've tried and it's not working.

When I put that code in the info disappears from the site if the field is empty, but if put some info on the field it doesn't show up. How can I make this work?

Thanks.

This is the code I've got:


[wpv-conditional if="( $(wpcf-como-chegar-ao-local) ne '' )"]<div class="archive-box">
  <div class="title-bar"><h3>Como chegar [types termmeta='como-chegar-ao-local-nome' output='raw'][/types]</h3>				</div>
  </div>[/wpv-conditional]

#575319

Noman
Supporter

Languages: English (English )

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

Hi Jorge,

Thank you for contacting Toolset support. Please try the below one and let me know if it works good or this one still has the same issue?

[wpv-conditional if="( NOT(empty($(wpcf-como-chegar-ao-local))) )"]
 <div class="archive-box">
    <div class="title-bar"><h3>Como chegar [types termmeta='como-chegar-ao-local-nome' output='raw'][/types]</h3>               </div>
   </div>
[/wpv-conditional]

Doc: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/

==> Please note that if you are checking a special field type like Checkboxes Field or Taxonomies, please use the example codes & instructions given in appropriate sections in the above doc.

Thank you

#575329

Hi Noman,

Thanks for the reply. When I insert the code you gave me the content doesn't display even though there is content in the field.

So, it doesn't work. This is a taxonomy term field. Don't know if that makes any difference.

Thanks.

#575439

Noman
Supporter

Languages: English (English )

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

Hello,

Okay, to further debug this issue, I need to request you please provide temporary access (WP-Admin and FTP Login info) to your site (preferably staging site), so that I can look into your setup and check the issue.

Your next answer will be private which means only you and I have access to it.

=== Please backup your database and website ===

✙ I would additionally need your permission to de-activate and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important.

✙ Please provide link to the [View/Content template/Page] where you are using this condition.

Thank you

#575668

Noman
Supporter

Languages: English (English )

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

Thank you for providing login details. I am working on this issue and will get back to you soon with an update.

Thank you for your patience.

#575697

Noman
Supporter

Languages: English (English )

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

Hello Jorge,

I created a new Category and Archive View to test it:
- Category archive page: hidden link
- Archive View: hidden link

- Assigned Terms field group to Categories for testing >> added value for the term field and you can see in the above category page link that it shows content based on condition.

- This is the conditional shortcode & syntax I have used for it, you can use this one where you need it:

[wpv-conditional if="( '[types termmeta='como-chegar-ao-local-nome'][/types]' ne '' )"]
 <div class="archive-box">
    <div class="title-bar"><h3>Term field is not empty:  [types termmeta='como-chegar-ao-local-nome' output='raw'][/types]</h3>               </div>
   </div>
[/wpv-conditional]

Doc I have used and the conditional syntax is - Checking Types plugin shortcodes (at the bottom of this page):
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-shortcodes-in-conditions/

On this page I can't see any text or content coming from Archive View. Even if I add basic text or any shortcode it does not show anything. Looks like there is a php archive file applied on it and henace archive view is not working on it:
[ category link removed ]

Thanks

#575718

Hi Noman.

Thanks for that!

It's working fine now. The code was slightly different from the one I have.

Is there way to keep the info and links private or remove it from these message exchange? The site is not yet live and I don't want it to be indexed by search engines.

I'm just going to leave the question for that privacy question.

Thanks.

#575727

Noman
Supporter

Languages: English (English )

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

Yes for sure, I have modified / removed links in above post so they are no longer readable.

Have a great day, Thank you

#575748

Thanks Noman!

The forum ‘Types Community Support’ is closed to new topics and replies.

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