Viewing 3 replies - 1 through 3 (of 3 total)
  • Is this within a wordpress post or page? It must be inside the loop for the shortcode to be rendered.

    Here are two ways of getting [short-codes] to display in your sidebar (outside the Loop).

    https://englishmike.net/2008/07/07/wordpress-quick-tips-3adding-a-shortcode-to-a-sidebar-widget/

    Login to your blog’s administration pages and go to the Theme Editor — i.e. select Design >> Theme Editor from the admin menu.
    Look in the list of Template Files on the right of the page for one called Theme Functions or functions.php and click on it to load it into the editor.
    Find a place between the <?php and ?> tags which is not in the middle one of the functions that may already be in the file (the very top or bottom of the file are both good places) and add the following line:
    add_filter('widget_text', 'do_shortcode');
    Click on the Update File button to save the modified template.
    That’s all you need to do.  Now any shortcodes you add to a sidebar widget will be correctly processed by the plugin they belong to.  The easiest way to test this is as follows:
    
    Go to Design >> Widgets using the administration menu.
    Find the Text widget in the list on the left, and click its Add button.
    Click on the new widget’s Edit link, and enter a title for the widget and then add the shortcode below it.
    Click the Change button, then click the Save Changes button (easy to forget) and then go to the front page of your blog to see your new shortcode-enabled widget.

    …also:

    To use your shortcodes outside of posts, pages, and the text widget, you could always call your shortcode function directly like this:
    $text = yourShortCodeFunction(‘[your shortcode tag here]‘);
    echo $text;

    I tried this and it worked in that it made the text widget recognize code. I was excited until I noticed that all of my page tabs on the menu had reverted back to the original text that came on the theme. I put the code that you gave in your first example in right after the <?php> tag and then I tried it right before the ?> tag and both had the same effect. I’d love to get this to work as I am using it with a file listing program that does not have a widget. If I can avoid it harming the rest of the page it should work really well.
    thanks for the info.
    Tim

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: WP-Weather] Short Code in sidebar instead of widget’ is closed to new replies.