This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Floating widget area as shortcode

  • Creator
    Topic
  • #2958
    odyn
    Participant

    I love the way I can add a floating widget area in a layout builder. But would it also be possible to add it into a page with a shortcode (or something) on its designated area?

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #2978
    Jason Bobich
    Keymaster

    I think you could pretty easily show a widget area in a shortcode, but it honestly really wouldn’t even have much to do with the theme. I suppose you’d be creating the widget area under Appearance > Widget Areas, but outside of that all the functionality would just be basic WordPress stuff. Something like this, maybe:

    [widget_area id="your-sidebar-id"]
    function my_widget_area_shortcode( $atts ) {
         ob_start();
         dynamic_sidebar( $atts['id'] );
         return ob_get_clean();
    }
    add_shortcode('widget_area', 'my_widget_area_shortcode');

    http://codex.wordpress.org/Function_Reference/add_shortcode

    http://codex.wordpress.org/Function_Reference/dynamic_sidebar

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.