Im having some trouble with my custom text widget and short-codes only rendering out as text.
in my functions file I have the required add_filters for short-codes to display in text widgets. Does this not apply for custom widgets with text fields / text areas? If so how do I filter specific text fields to render the short-codes properly. I have tried just about everything and its driving me crazy.
As I said before I have the below filters in my funtion.php and they work for the standard text widget.
add_filter(‘widget_text’, ‘shortcode_unautop’); add_filter(‘widget_text’, ‘do_shortcode’);
For arguments sake lets say I want to add the filter to:
$box1message = $instance['box1message'];
and then I call box1message like so:
any help would be SUPER !
add_filter('widget_text', 'shortcode_unautop'); add_filter('widget_text', 'do_shortcode');
^ thanks for the reply, but (as I said above) I already have that in my functions.php … it doesn’t work on custom widget text fields?..
EDIT : I should clarify that it DOES work on the standard text widget supplied by wordpress. However it does NOT work in my custom widget text fields.
Sorry read through quick and missed that…. But if it’s not working then something else is likely wrong either with your widget code or shortcode
That’s ok I have a few WP themes lying about and they all have the same problem. These WP themes are by other authors aswell. Probably something to do with how I register the widget then. hmmmm.
I found this thread while trying to solve this problem myself, and I’ve just got it working
you’ve probably solved this by now but just in case you haven’t, and for the sake of other people having this problem…
in your custom widget code, instead of using a basic echo to output $instance[‘box1message’], try doing it like this:
echo apply_filters(‘widget_text’, $instance[‘box1message’]);
that works for me!
I am trying to do the same but with no results….
I am trying to use shortcodes in some custom widgets created by themeforest authors… but I cannot, I don´t know why..
In my functions.php I have the add filter to use shortcodes in widget_text, but even if I use the solution writen by mattie_prescott the widget showns the “text” but not the shortcode…
For example, I am trying to customize the Resporsive theme for a client (bought by him, so I cannot ask the author with my account), and I cannot run shortcodes in the custom widgets like the “resports_text_widget” or the “resports_tabs_widget”...
Can someone help me?
Thanks in advance!
sorry I’m not sure why your shortcodes aren’t working, but if the shortcode isn’t being displayed at all, then that would suggest to me that it is being processed by wordpress, it’s just not outputting anything?
Have you had any luck with this?