310 posts
  • Has referred 50+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+3 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 !

3437 posts
  • Has sold $5,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Located in United States
  • Has been part of the Envato Community for over 4 years
+1 more
organicbee says
add_filter('widget_text', 'shortcode_unautop');
add_filter('widget_text', 'do_shortcode');
310 posts
  • Has referred 50+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+3 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.

3437 posts
  • Has sold $5,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Located in United States
  • Has been part of the Envato Community for over 4 years
+1 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

310 posts
  • Has referred 50+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+3 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
  • Has been part of the Envato Community for over 2 years
  • Has collected 1+ items on Envato Market
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
  • Has been part of the Envato Community for over 2 years
  • Has sold $1+ on Envato Market
  • Sells items exclusively on Envato Market
  • Located in 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
  • Has been part of the Envato Community for over 2 years
  • Has collected 1+ items on Envato Market
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
  • Has referred 10+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Has been part of the Envato Community for over 3 years
+2 more
SyamilMJ says

echo do_shortcode($box_one_message);

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by