Help Center
Cannot Hide a Widget if a Meta Field Is Empty

Cannot Hide a Widget if a Meta Field Is Empty

I cannot hide a widget when the meta field is empty. How do I set it up?

Answer
Modified on: Thu, 24 Apr, 2025

Although this setup seems to check for the presence of content in the meta field, it does not operate correctly.

wrong setup

Please note that a different condition should be used to make Dynamic Visibility work properly. 

As an example, we will try to hide the Dynamic Field widget when the “Additional Info” Textarea meta field is empty. 

So, let’s proceed to the Dynamic Visibility section in the Advanced tab and turn on the Enable toggle.

dynamic visibility tab opened

In the Visibility condition type field, we leave the “Show element if condition met” option.

show element if condition met option

Let’s set up the сondition now. From the Condition dropdown, select the “Regexp” option.

regexp option chosen in the condition field

Click the “Dynamic Tag” icon on the right side of the Field selector. Scroll down to the JetEngine section and choose the “Custom Field” option.

dynamic tag dropdown menu with custom field option visible

In a newly appeared pop-up, pick the meta field from the dropdown (the “Additional Info” field in our case).

custom field selected in the regexp condition settings

The last point — we put “.+” in the Value field.

.+ value is set in the value field

When working with JetEngine features like Custom Queries, Dynamic Visibility Conditions, or Filters, you might come across the regular expression “.+”, where the “.” (dot) matches any single character, except line breaks, and “+” means one or more of the preceding element.

So, “.+” matches any non-empty value — it’s useful when you want to check if a field contains at least one character (not just spaces or an empty string).

We leave the Context and Data Type fields with their default settings.

Things to know

Please, be aware that the described setup works for the “Text,” “Textarea,” “Number,” “Checkbox,” “Select,” and “Radio” meta field types.

save as array toggle is activated
Warning

When setting up Dynamic Visibility based on the “Checkbox” meta field’s content, ensure that the Save as array option is enabled. If this field is completed in the Custom Post Type and the Save as array toggle is activated, the field will be reset, and the data will need to be filled in again.

Additionally, it’s worth noting that the setup of the Dynamic Visibility feature will be different when the Switcher field is used as the source for the content. 

In this case, the “Switcher enabled” Condition should be selected.

switcher enabled condition selected for the switcher field

Choose the needed custom field in the same way we described above.

Now, let’s see how it works on the front end. 

We will check two posts: one has content added to the “Additional Info” meta field and the “Certified Doctor” Switcher enabled, and the second post doesn’t have any of that. 

For this post, we see the Dynamic Fields display the data.

additional info and certified doctor displayed on the front end

The second post has the “Additional Info” meta field empty and the Switcher turned off, so the widgets are hidden.

widgets are hidden on the front end

Now you know how to hide widgets according to the meta fields’ content with the help of the Dynamic Visibility functionality from the JetEngine plugin for WordPress.

Was this article helpful?
YesNo

Need help?

Ask Facebook community

Get answers from 30K+ Crocoblock Community experts from all over the world.

Start a live chat

Ask question to support agent and share its details via chat messages.