368 posts
  • Affiliate Level 4
  • Author Level 8
  • Collector Level 2
  • Elite Author
+5 more
visualkicks
says

Hi Guys,

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:

echo $box1message;

any help would be SUPER !

3439 posts
  • Author Level 4
  • Collector Level 2
  • Community Superstar
  • United States
+2 more
organicbee
says
add_filter('widget_text', 'shortcode_unautop');
add_filter('widget_text', 'do_shortcode');
368 posts
  • Affiliate Level 4
  • Author Level 8
  • Collector Level 2
  • Elite Author
+5 more
visualkicks
says

^ 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.

3439 posts
  • Author Level 4
  • Collector Level 2
  • Community Superstar
  • United States
+2 more
organicbee
says

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

368 posts
  • Affiliate Level 4
  • Author Level 8
  • Collector Level 2
  • Elite Author
+5 more
visualkicks
says

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.

2 posts
  • 3 Years of Membership
  • Collector Level 1
mattie_prescott
says

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!

1 post
  • 3 Years of Membership
  • Author Level 1
  • Exclusive Author
  • Spain
+2 more
rjcalvente
says

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!

2 posts
  • 3 Years of Membership
  • Collector Level 1
mattie_prescott
says

rjcalvente,

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?

316 posts
  • Affiliate Level 2
  • Author Level 5
  • Collector Level 2
  • 4 Years of Membership
+2 more
SyamilMJ
says

echo do_shortcode($box_one_message);

by
by
by
by
by
by