[Resolved] Hide field if empty

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.

Our next available supporter will answer your ticket in about 5.88 hours from now. Thank you for your understanding.

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://wp-types.com/forums/topic/hide-field-if-empty/#post-575697

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

Tagged: 

This topic contains 8 replies, has 2 voices, and was last updated by  JorgeE7101 2 months, 2 weeks ago. The support staff assigned to this topic is Noman.

Viewing 9 posts - 1 through 9 (of 9 total)
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
Forum moderator

Supporter languages: English (English )

Supporter 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://wp-types.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
Forum moderator

Supporter languages: English (English )

Supporter 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
Forum moderator

Supporter languages: English (English )

Supporter 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
Forum moderator

Supporter languages: English (English )

Supporter 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://wp-types.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
Forum moderator

Supporter languages: English (English )

Supporter 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!

Viewing 9 posts - 1 through 9 (of 9 total)