add_shortcode support in Widgets

  1. OfficeVoodooKit

    It would be great if there was a checkbox on a widget that would enable it to recognize shortcut code from plugins.

    An example is [CSSBUTTON target="http://www.linktarget.com" color="000000" textcolor="ffffff"]Button Caption[/CSSBUTTON]

    The above code is from the WP CSS Button plugin

    Posted: 7 years ago #
  2. Justin Tadlock
    WordPress God

    Adding this to your theme's functions.php should work:

    add_filter( 'widget_text', 'do_shortcode' );

    I'm undecided on whether this should be allowed in widgets by default yet.

    Posted: 7 years ago #
  3. Andy Macaulay-Brook


    Keep it optional rather than adding search and replace across all your live widgets.

    Posted: 7 years ago #
  4. Jer Clarke


    The filter method works but is very onerous. Going forward I find myself using widgetized sidebars for everything, and having shorcodes in there just makes sense!

    Having a setting for shortcode parsing in widgets would mean that plugin devs don't have to create a widget, they can just give a shortcode that doesn't break as a shortcode in text widgets!

    I don't think making shortcodes work by default in widgets will hurt very many people due to the content already in their widgets, and for all future text widgets it will be very very useful.

    If shortcode parsing isn't the new default then there should be a setting to make them work. Logically it would belong with the checkbox for paragraph parsing on each widget. Personally I think having a setting deeper in WP would make more sense, as setting this for a whole site will almost always be a possibility.

    Posted: 7 years ago #

RSS feed for this topic


You must log in to post.

  • Rating

    6 Votes
  • Status

    This idea has been implemented