WidgetShortcode WordPress Plugin

Want to use shortcodes in your sidebar? Now you can.  Simply install and activate WidgetShortcode and you can start adding shortcodes to the standard Text widget on your sidebar.

In the past you would need to edit functions.php in your theme to get this functionality.  Now you no longer need to worry about modifying the file or changing themes causing your sidebar to break.

Installation

  1. Download the WidgetShortcode plugin and extract it into the wp-content/plugins directory. This should create a widget-shortcodes subdirectory.
  2. In the Plugins menu, activate WidgetShortcodes.
  3. Relax and enjoy!

Settings

There are no settings for the plugin — it works as soon as it’s activated. To turn it off deactivate the plugin.

Notes

This has currently only been tested in WP 2.9.2.  I can’t see why it wouldn’t work in older versions that support shortcodes (I believe 2.5 was the first) and the Text widget.

The plugin is licensed under GPL version 3.

This plugin works by hooking do_shortcode to the widget_text filter.  It also hooks shortcode_unautop if that function exists.  This should help in older versions.

There are no settings for this plugin.

Donations

If you would like to donate towards this plugin feel free to use the PayPal button below to do so.


Be Sociable, Share!

19 Comments on WidgetShortcodes

  1. Joe Jenkins says:

    It looks like a great plugin and very useful, but it doesn’t seem to want to work with my test.

    I’m trying to use the shortcode for Facebook Photo Fetcher, but it just shows up as blank :(

  2. LoneWolf says:

    Hi Joe

    I did a bit of research on Facebook Photo Fetcher and it does not actually use shortcodes. It is using html comment tags. Shortcodes always start with [ rather than <.

    According to their documentation you’ll need to create a custom widget if you want it to appear in a sidebar.

    I suppose that you could create a shortcode to call the fpf_fetch_album_content() function and then use my plugin to allow it to be called from a text widget. That may be simpler than creating a widget.

    Thanks for trying out WidgetShortcodes.

  3. Joe Jenkins says:

    Thanks for looking into it, it certainly explains the problem.

    Now I can test out some other shortcodes and make life easier :)

  4. LoneWolf says:

    No problem Joe. Glad to help.

    Have fun! Are you using this for the Jace Hall Show site? Let me know where it’s being used so I can see the results.

  5. C J says:

    Hi there. Great Plugin, worked first time. Thank you !

  6. Mike says:

    I have a video lightbox plugin installed. It uses the following shortcode in a post, as an example:

    [video_lightbox_youtube video_id=Ar5ghTN9r78 width=640 height=480 anchor=play video]

    But, it does not work with your plug in inside a text widget.

    Is the ability for your plugin to work dependent on only WP shortcode?

    Mike

  7. Joe says:

    Sorry I didn’t reply earlier (a whole year, blimey). For some reason the email reply hadn’t come through.

    I’m going to be using this on my new service preoviding writers with sites, so will let you know once that is live so you can see how it looks (and use it to market the plugin).

  8. LoneWolf says:

    Hi Mike

    As far as I know there are no problems with the plugin. Does the actual shortcode text show up in the widget or is it simply not there? Or is there an error message?

    It is possible that some other plugin or theme function is stripping out shortcodes before the text widget can see it.

    It could also be something that the lightbox plugin is doing. There is likely a div or something that is added somewhere for the javascript to mess around with and it might not be getting put properly in when the shortcode isn’t in the page itself.

    If you can give me a link to an example of the site I might be able to figure out what is happening. It would also be helpful to see an example of the lightbox working inside a page or post since I could look at the code that is being generated for a working sample.

  9. Mitch says:

    Hi, I just tried the plugin and can’t seem to get it to work. I’m using a shortcode in a post and it works. When I try the same shortcode in a widget, after activating the plugin, it’s just showing the shortcode. You can see this at the site. The form is seen on the landing page, but in the right column it show the code. Any thoughts?

    • LoneWolf says:

      Hi Mitch

      I’ve checked out your site and I don’t see anything wrong. I’m assuming you’re dealing with the signup for the newsletter. I see it both in the landing page and the sidebar.

      Have you changed from using the shortcode?

      I’ve heard of people having trouble with using shortcodes in widgets (with or without this plugin) since WP 3.0 but people that I developed it for initially haven’t reported any problems.

      I can’t imagine it being browser related since the PHP is all run on your server, so if it works for me it should work for you. But just in case, let me know what browsers you’ve tested it in. I use Firefox.

      Also, you may want to clear your browser cache in case it has a copy of the page it got before you activated the plugin. It’s a long shot but it is something to try.

      Let me know how it turns out.

  10. amita says:

    Hi,
    I’ve set up some of my WordPress blogs recently…and now going to try this plugin….and let you know how it works for me.
    thanx

  11. Rick Daniel says:

    Hi LoneWolf,

    The plugin worked perfectly but the text widget I inserted the shortcode in disappeared from the widget menu. I don’t know how to retrieve it for changes. I am using WP 3.3.1. Hope that’s not the issue. I don’t mind leaving it alone for now but I won’t use it on any other sites until I learn how to see the widget again.

    I used the plugin to display social media recommend buttons.

    http://homeinspectorinc.com

    Rick

  12. Rick Daniel says:

    Oh. Never mind. The text widget showed up when I left the widgets page and came back in. Sleepy WordPress I guess.

    Rick
    Rick Daniel recently posted…DYK Only 23 CMI’sMy Profile

    • LoneWolf says:

      Hi Rick

      I’m glad that it sorted itself out. That would be something to do with the way WordPress itself works rather than the plugin.

      I checked out your site to see how you’re using it. Looks pretty cool. I wish my home inspector found gold mines on my property 8=)

      • Rick Daniel says:

        Hi LoneWolf,

        Thanks for having a look. I wish I had a gold mine too! :-) Since you are so proficient with WordPress did you notice the gap between the bottom of my top nav menu and the first H1 line on the page? All the pages got “stretched” a while back when I inadvertently uploaded a really large image. The are no paragraphs of line breaks in the HTML so I don’t know how to correct that. Any suggestions?
        Rick Daniel recently posted…DYK Only 23 CMI’sMy Profile

        • LoneWolf says:

          Hi Rick

          I took a look at the HTML for the site that WordPress is generating and there are two line break tags (<br />) before the H1.

          I checked a couple of different pages and some have the same thing and others don’t. It looks like the ones that do are using a different template than the others.

          It is most likely that the extra line breaks have been added to one or more of the template files of the theme you’re using. That would be the first place I would look.

          It is also possible that there may be some setting in the theme that is adding this. If there are theme options under the Appearance menu that allow inserted HTML code in various places this could be the cause.

          Another possibility is a plugin somewhere is adding the code. The easiest way to check that is to disable plugins one at a time and see if it corrects itself.

          Hopefully this will get you started in the right direction!

  13. Rick Daniel says:

    Thank you LoneWolf,

    I never thought to view the source. I was just looking on the HTML side of the “Edit page”. Thank you for your help. I am determined to track this down.

    Watch for a “Donation”. Rick
    Rick Daniel recently posted…DYK Only 23 CMI’sMy Profile

  14. Michael Sheridan says:

    Really great plugin. Thankyou. You have just made life much easier for one of my clients.
    I have given you a short review and a backlink from my site and will refer more customer I am sure:
    http://www.artisan-solutions.n.....s-widgets/

Leave a Reply

CommentLuv badge

This blog uses premium CommentLuv which allows you to put your keywords with your name if you have had 3 approved comments. Use your real name and then @ your keywords (maximum of 3)