149 posts
  • Elite Author
  • Exclusive Author
  • Sold between 100 000 and 250 000 dollars
  • Australia
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Has been a member for 2-3 years
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 !

3117 posts
  • Sold between 5 000 and 10 000 dollars
  • United States
  • Bought between 10 and 49 items
  • Has been a member for 3-4 years
  • Exclusive Author
chrisakelley says
add_filter('widget_text', 'shortcode_unautop');
add_filter('widget_text', 'do_shortcode');
149 posts
  • Elite Author
  • Exclusive Author
  • Sold between 100 000 and 250 000 dollars
  • Australia
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Has been a member for 2-3 years
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.

3117 posts
  • Sold between 5 000 and 10 000 dollars
  • United States
  • Bought between 10 and 49 items
  • Has been a member for 3-4 years
  • Exclusive Author
chrisakelley 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

149 posts
  • Elite Author
  • Exclusive Author
  • Sold between 100 000 and 250 000 dollars
  • Australia
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Has been a member for 2-3 years
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
  • Bought between 1 and 9 items
  • Has been a member for 1-2 years
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
  • Sold between 1 and 100 dollars
  • Spain
  • Exclusive Author
  • Referred between 1 and 9 users
  • Bought between 50 and 99 items
  • Has been a member for 1-2 years
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
  • Bought between 1 and 9 items
  • Has been a member for 1-2 years
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?

308 posts
  • Attended a Community Meetup
  • Sold between 10 000 and 50 000 dollars
  • Exclusive Author
  • Bought between 10 and 49 items
  • Has been a member for 2-3 years
  • Referred between 10 and 49 users
SyamilMJ says

echo do_shortcode($box_one_message);

by
by
by
by
by
by