Function to hide widget
-
Hi,
Does a hook exist to hide the widget? (i know that there is this one to hide it if it’s empty: add_filter( ‘black_studio_tinymce_hide_empty’, ‘__return_true’ );).I want one that just hides, I would then add an IF statement to hide it on a condition.
I have shortcodes in my widget to display custom fields, and sometimes the custom fields are empty, so I don’t want it to display if they are empty. The widget itself isn’t empty though because it has the shortcodes so the existing hook above doesn’t work for me.
Thanks
-
This topic was modified 8 years, 8 months ago by
lananas1.
-
This topic was modified 8 years, 8 months ago by
-
Hi @lananas1,
I’d suggest to use of the following approaches:
- The
sidebars_widgetsfilter hook, which is a general purpose filter that allows you to filter all the widget types. See documentation https://developer.ww.wp.xz.cn/reference/hooks/sidebars_widgets/ - The Widget Logic plugin, which allows you to define conditions for each widget using your own PHP code.
There are several other plugins for conditional widget display, but this one is the most dev-oriented.
Great, thanks for your help!
Hi Everyone,
You might want to check Widget Options : https://ww.wp.xz.cn/plugins/widget-options/ for conditional widgets plugin. @marcochiesi I hope you’ll love the plugin feature and will be able to recommend it instead of Widget Logic. Thank you very much!
Cheers,
JeffreyHi @phpbits,
I just tested your plugin and at first sight it looks really good and complete. Thanks for the suggestions, I will definitely recommend it.Thank you very much @marcochiesi, I’m really glad that you love the plugin features and thank you in advance for your recommendation 🙂
Cheers,
Jeffrey - The
The topic ‘Function to hide widget’ is closed to new replies.