• Resolved indigotimberlake

    (@danielpitulia)


    Hello!

    I am currently working on a store using the Boutique child theme for Storefront. However, I’m stuck trying to add a sidebar for the shop page and was hoping someone could point me in the right direction!

    The problem is that the Sidebar widget shows the same sidebar in the shop and the blog page and I want them to have different sidebars… I managed to create a new widget area for the shop by adding the following code to my custom functions.php (I am using a plugin to add custom css and functions because editing this child theme was not recommended).

    function arphabet_widgets_init() {
    
    	register_sidebar( array(
    		'name'          => 'Shop sidebar',
    		'id'            => 'sidebar-shop',
    		'before_widget' => '<div>',
    		'after_widget'  => '</div>',
    		'before_title'  => '<h2 class="rounded">',
    		'after_title'   => '</h2>',
    	) );
    
    }
    add_action( 'widgets_init', 'arphabet_widgets_init' );
    ?>

    I have also added a sidebar-shop.php file with basically the same code as the normal sidebar.php file.

    <?php
    /**
     * The sidebar for shop.
     *
     */
    
    if ( ! is_active_sidebar( 'sidebar-shop' ) ) {
    	return;
    }
    ?>
    
    <div id="secondary" class="widget-area" role="complementary">
    	<?php dynamic_sidebar( 'sidebar-shop' ); ?>
    </div><!-- #secondary -->

    From this point I’m stuck. I tried to find an archive-products.php file to change the get_sidebar somehow. I know i need to find the page that controls the shop and then add some code in order to make it retrieve the correct widget but the naming conventions in Boutique and Storefront is really confusing me..

    Does anyone know how to make the widget appear in the shop? I was hoping someone here might know how to fix this…

    Best regards,
    Daniel

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hey,

    Have you tried WooSidebars? ??

    Thread Starter indigotimberlake

    (@danielpitulia)

    Hi,

    Actually, I read about it in older threads when I tried to find a solution. I was hoping to solve this without using a plugin. It seems like it doesn’t need a lot of code. Also, I’m really trying to learn developing on my own so I guess a plugin defeats the purpose… If I can’t find a solution, I guess I will use the plugin or create my own child theme of storefront and customize that one instead.

    Thanks though!

    I see.

    Well, looking at your code, it looks to be OK. I assume you added widgets to the sidebar? ??

    Thread Starter indigotimberlake

    (@danielpitulia)

    I think I understand the process of adding new widget areas a bit better now. I basically broke it down into three major steps:

    1. Add a function, e.g. arphabets_widgets_init() which contains register_sidebar, explained here Widgetizing Themes.

    2. Call the function to create a widget area, for example:
    arphabets_widgets_init(‘Sidebar’, ‘Sidebar’, ‘Side bar for Pages’);

    3. Place the function dynamic_sidebar( ‘Sidebar’) in page.php or wherever you want the sidebar to appear.

    To create a separate widget area for a shop sidebar, I guess just need to follow these steps and change the dynamic_sidebar() in the shop template!

    Anyway, Im going to practice some more with creating widget areas. Thanks for the help!

    @danielpitulia did you get it to work?
    I also look for the same solution and want to keep plugins to minimum. If it works please share with us.
    Thanks

    @jameskoster this functionality really should be built in storefront, as many people choose WooCommerce because they want Store + Blog. So 2 different sidebars is a must have.
    Thanks

    ‘A must have’ is entirely subjective. In my experience, most people don’t even use the blogging functionality – they use Storefront solely as a store.

    Anyway, if you need custom sidebars, simple install the WooSidebars plugin and you’re good to go.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Customized sidebar for shop page’ is closed to new replies.