- This topic has 3 replies, 2 voices, and was last updated 13 years, 10 months ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- The forum ‘How do I …’ is closed to new topics and replies.
Events Made Easy › Forums › How do I … › Shortcode in a Widget
I was just curious what your thoughts were on adding
if (!is_admin()) add_filter(‘widget_text’, ‘do_shortcode’, SHORTCODE_PRIORITY);
to your plugin so that people could run the shortcode from text widgets. I just added it to my theme’s functions.php file but thought it’d be useful for your users to be able to run any combination as a widget.
RE: http://hackadelic.com/the-right-way-to-shortcodize-wordpress-widgets
Thanks again for all you do!
Andrew
Well, I could add it of course. Does this mean that people could use all the shortcodes outside pages, in widgets? An implementation example would be nice 🙂
Well, I won’t add this since it influences all widgets and all shortcodes and I don’t like it when my plugin changes generic behaviour. But the correct way to do it is either:
– add the following to your functions.php:
if (!is_admin()) add_filter('widget_text', 'do_shortcode', 11);
– or use http://hackadelic.com/wordpress-online-tools/wordpress-tweaks-composer to create a small plugin that just activates this for you.
For reference: I added an option that allows this to to be set in the settings page (shortcodes in widgets)