Home>Support>Using a shortcode in SiteOrigin Hero

Using a shortcode in SiteOrigin Hero

I am using the SiteOrigin Hero Widget. Inside of the frame, I would like to use a shortcode of my own plugin:

<p style="text-align: center;">[my_shortcode]</p>

But it only displays

[my_shortcode]

I tried enabling the shortcode for widgets by calling

add_filter('widget_text', 'do_shortcode');

in my plugin and it works for usual WP widgets, but not inside of the SiteOrigin Hero widget. What can I do to make it work?

Thanks in advance,

Kilian

This is a free community support forum. Replies are not guaranteed. If you need professional email support, please purchase a SiteOrigin Premium license.

  1. 25 days, 3 minutes ago Alex S Hi, I Work Here

    Hi Kilian,

    That’s odd. Shortcodes should be working without issue. Can you please send me a copy of your shortcode so I can run some tests?

  2. 24 days, 1 hour ago kilian.batzner

    Hi Alex, thank you for your response. I reproduced the issue with a simple plugin:

    <?php 
    /*
    Plugin Name: my-plugin
    Description: test
    Version: 0.1
    Author URI: mailto:info@kilians.net
    */
    
    // Enable shortcodes in text widgets
    add_filter('widget_text', 'do_shortcode');
    
    add_action('init', 'my_shortcode_init');
    function my_shortcode_init()
    {
        add_shortcode('my_shortcode', 'my_shortcode_func');
    }
    
    function my_shortcode_func()
    {
    	return 'It works!';
    }

    These are the steps to reproduce it:
    – Install WordPress 4.8.2 with the default Twenty Seventeen theme
    – Install and activate the current SiteOrigin Widgets Bundle Plugin (1.10.2)
    – Activate the my-plugin.php plugin (code above)
    – Add the SiteOrigin Hero widget to the sidebar with [my_shortcode] in the frame
    – Add a text widget to the sidebar with [my_shortcode] as text

    This is the resulting sidebar:

    screenshot

  3. 18 days, 8 hours ago Alex S Hi, I Work Here

    Hi Kilian,

    I just double checked the code and I’m mistaken.

    Unfortunately, shortcodes intentionally don’t currently work with the SiteOrighn Hero widget. I’m going to log this as a feature request but in the meantime, I recommend using the SiteOrigin Layout Slider instead. Can’t see this widget? You can activate it by navigating to WP AdminPluginsSiteOrigrn Widgets.

Please log in to post on our forums. Signing up is free.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More