Site logo

Archived topic

wocommerce sidebar

3 replies · Started by sg on April 13, 2018

Viewing posts 1–4 of 4

Hi guys, i read many topics regarding this but some were outdated. hoping to get some latest update :)

Loving GP !

the case is i need a custom sidebar for my woocommerce and all its related pages. i tried few sidebar and widget plugins but nothing works with woocomerce.

so i assume now my only solution is to register a sidebar and add it as snippet .

1. register sidebar , is this the code ? ps mysidebar name is Shop-Sidebar

function arphabet_widgets_init() {

	register_sidebar( array(
		'name'          => 'Shop-Sidebar',
		'id'            => 'shop-sidebar',
		'before_widget' => '<div>',
		'after_widget'  => '</div>',
		'before_title'  => '<h4>',
		'after_title'   => '</h4>',
	) );

}
add_action( 'widgets_init', 'arphabet_widgets_init' );

add_action('generate_woocommerce_sidebars','generate_contsruct_sidebars');
function generate_contsruct_sidebars()
{
	get_sidebar('Shop-Sidebar'); 
	
}

2. call in sidebar for wc

add_action( 'wp','tu_woocommerce_sidebar' );
function tu_woocommerce_sidebar()
{
    if ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) {
        remove_action( 'generate_sidebars','generate_construct_sidebars' );
        add_action( 'generate_sidebars','tu_construct_woocommerce_sidebar' );
    }
}

function tu_construct_woocommerce_sidebar() {
    get_sidebar( 'Shop-Sidebar' );
}

i know somewherer is wrong , pls correct me , thanks !

i manage to solve it ,
just need to search sidebar manager that support woocommmerce.
codecanyon has few.

thanks Leo for looking into this. cheers !

Awesome :)

Glad you found the solution!

This archived topic is closed to new replies.