Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've installed the Jigoshop plugin to create an e-commerce site. It has several built in widgets that I want to use. Is it possible to pull out specific widgets and display them within a page template?

Within Jigoshop it's specifically the cart, product search and layered nav. I don't just want to display them one under another. I want the cart in the top right of the page with the product search and nav on the left of the page so I need control of each one really.

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

You will want to create a new widget area or dynamic sidebar in your theme's code. Justin Tadlock has a great tutorial about how to do this, but the basics boil down to this.

  1. Add the widget area declaration in your theme's functions.php file:

    <?php
    add_action('widgets_init', 'my_register_sidebars');
    function my_register_sidebars() {
    /* Register the 'cartwidgets' sidebar. */
    register_sidebar(
        array(
            'id' => 'cartwidgets',
            'name' => __( 'Cart Widgets' ),
            'description' => __( 'A short description of the sidebar.' ),
            'before_widget' => '<div id="%1$s" class="widget %2$s">',
            'after_widget' => '</div>',
            'before_title' => '<h3 class="widget-title">',
            'after_title' => '</h3>'
        )
    );
    }
    ?>
    
  2. Then in the appropriate files in your theme (page.php, single.php, index.php, etc.) include code similar to the following to actually show the new widget area:

    <div id="sidebar-primary" class="sidebar">
        <?php dynamic_sidebar( 'cartwidgets' ); ?>
    </div>
    

Those are the basics, but I would highly recommend you read Tadlock's post, as he's done a great job of explaining all of the parameters and pitfalls. Doing this, you'll be able to drag the cart's widgets into these new sidebars and they will show up, just as WordPress is designed.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.