Search code examples
wordpresshtmlwidgetfixed

Load Wordpress widget in a fixed div


I'm working on a site that sells various products. Currently we're presenting those products as fixed width (no sidebar) pages within Wordpress. I'm using "Simple WP Shopping Cart" to drive the transactions (because all of the other solutions are bloated and break stuff). With this plugin you get a widget that contains the cart...

What I want to do is load that cart to a fixed div that sits on the side of the page, rather like all those "feedback" and "socialise" bars you see on a variety of sites these days. I've done the div, so that's not a problem, but I can't seem to get the widget to load.

So basically: how would one go about loading widgets, or a widget, in a div that isn't the "designated" sidebar in Wordpress?


Solution

  • you need to "designate" it as a sidebar... :-)

    A "sidebar" is actually a placeholder for widgets .

    <div id="mysidebar">
       <?php dynamic_sidebar( 'Right Sidebar' ); ?>
    </div>
    

    from the codex :

    You can load a specific sidebar by either their name (if given a string) or ID (if given an integer). For example,

    dynamic_sidebar('my_name')

    will make a sidebar (widget placeholder) for a registered sidebar with :

    register_sidebar(array('name'=>'my_name',)). 
    

    read here for more : http://codex.wordpress.org/Function_Reference/dynamic_sidebar