WordPress.org

Forums

Shortcode in widgets not working (20 posts)

  1. smoore217
    Member
    Posted 2 years ago #

    Hi,

    I cannot get shortcodes to work in text widgets to save my life. I heard that this is enabled by default in the latest wordpress, however it will not work. I also tried adding add_filter('widget_text', 'do_shortcode'); to my functions.php file for the theme, but the shortcode still shows up as a string. Was this feature broke in the newest version of wordpress?

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    I heard that this is enabled by default in the latest wordpress

    Then I'm afraid your sources were incorrect.

  3. smoore217
    Member
    Posted 2 years ago #

    It was probably from 6 months ago when this: http://core.trac.wordpress.org/ticket/10457 had the release set for version 3.3. Anyway, my problem still stands.

  4. esmi
    Forum Moderator
    Posted 2 years ago #

    If you check the Trac ticket, it's been changed to "Future Release". At present, the only shortcodes that will work in widgets are those specially created by plugins.

  5. smoore217
    Member
    Posted 2 years ago #

    Can you move this to the plugins&hacks forums then as this is a known hack and deals with troubleshooting it.

  6. esmi
    Forum Moderator
    Posted 2 years ago #

    It's not a known hack and it does belong in this forum.

  7. smoore217
    Member
    Posted 2 years ago #

    If it isn't a known hack, then why are there tons of articles littering the internet with the add_filter('widget_text', 'do_shortcode'); solution I attempted?
    http://digwp.com/2010/03/shortcodes-in-widgets/
    http://www.wprecipes.com/how-to-add-shortcodes-in-sidebar-widgets
    http://dannyvankooten.com/630/enabling-shortcodes-in-widgets-quick-wordpress-tip/
    http://englishmike.net/wordpress/2008/07/07/wordpress-quick-tips-3adding-a-shortcode-to-a-sidebar-widget/

    These all cover the same solution, which is not working. It causes behavior not intended in original design, so I'd consider that a hack.

  8. esmi
    Forum Moderator
    Posted 2 years ago #

    It is not a core hack.

  9. smoore217
    Member
    Posted 2 years ago #

    I don't think the "plugins and hacks" forum consists of very many core hacks... I'd figure this forum is meant for troubleshooting installation and base functionality problems.

  10. esmi
    Forum Moderator
    Posted 2 years ago #

    Hacks
    – For Plugin Coding and Core hacking discussion

  11. smoore217
    Member
    Posted 2 years ago #

    Plugins and Hacks
    – Extensions and modifications

    This is the forum I wanted it transferred to, not Hacks.

  12. esmi
    Forum Moderator
    Posted 2 years ago #

    That is for plugins only.

  13. clawler
    Member
    Posted 2 years ago #

    While this semantics argument was entertaining was a solution to this issue ever found? I'm having the same problem.

    Smoore217, did you end up posting this issue elsewhere? Any luck?

    Thanks.

  14. alchymyth
    Forum Moderator
    Posted 2 years ago #

    @clawler

    neither you nor the original poster are clear about what shortcodes you were trying to show in the textwidget of what theme.

    without these details, this is really just a philosophical topic.

    it might possibly be better if your start your own topic and post the necessary details.

  15. clawler
    Member
    Posted 2 years ago #

    Thanks alchymyth, just wanted to see if a solution ever presented itself.

    Right now I'm using Twenty Eleven in 3.4.2 and it's with any shortcode I try. I'm also using one of the many single line Shortcode in Widget plugins. I've also tried putting add_filter('widget_text', 'do_shortcode'); in the functions file myself, but that didn't work either.

    Any recommendations?

  16. alchymyth
    Forum Moderator
    Posted 2 years ago #

    it's with any shortcode I try

    considering that [gallery] and [caption] are the only genuine shortcodes, and that somethings in [brackets] is not always shortcode, what exact other shortcodes have you tried?

  17. clawler
    Member
    Posted 2 years ago #

    No way! I can't just stick things in brackets to [make-it-magically-work]!?

    I haven't tried those exactly but I did try five or six off of the WordPress shortcode list: http://en.support.wordpress.com/shortcodes/. The one I'd assume would work was [archives] because even the WordPress support page says that it should work in a text widget (http://en.support.wordpress.com/archives-shortcode/). I've tried it with specific plugin shortcodes as well (i.e. soliloquy and tubepress).

    Thought that one of the plugins might of been effecting it but I've deactivated all of them and still no luck.

  18. alchymyth
    Forum Moderator
    Posted 2 years ago #

    off of the WordPress shortcode list

    you are quoting from WordPress.com - this list does not exist in WordPress.org

    [gallery] and [caption] are the only genuine WordPress.org shortcodes.

    so what legitimate shortcodes have you tried?

    ps:

    No way! I can't just stick things in brackets to [make-it-magically-work]!?

    you will be surprised what some users are trying ;-)

    this was a serious remark as some 'square bracket codes' from plugins are no shortcodes, and still some people try to use the 'do_shortcode()' function on it.

  19. clawler
    Member
    Posted 2 years ago #

    I was able to get [caption] working, or at least I didn't see the shortcode. Still, not sure why the other shortcodes do not work. Will only [caption] and [gallery] work in the text-widget?

    In either case I found a work-around for my larger issue, thanks for the help.

  20. alchymyth
    Forum Moderator
    Posted 2 years ago #

    any shortcode which is based on a function or a plugin, or came as part of your theme, should work in a textwidget (provided you have add_filter('widget_text', 'do_shortcode'); in functions.php of your theme).

Topic Closed

This topic has been closed to new replies.

About this Topic