'How to add a sidebar to Woocommerce Shop Page?
So, I'm making my own theme from scratch for Wordpress with the Woocommerce plugin. I can seem to find how to add a sidebar widget to my Shop page... There is no area for it in thw Widgets menu and I can't seem to find how to create it and edit it...
Can someone help me understant how to create it and which files/code do I need to create in my child theme?
Solution 1:[1]
You need to create a widget area in your functions.php with this function :
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Sidebar',
'before_widget' => '<div class = "widget">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
)
);
And for display in your theme :
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Sidebar") ) : ?>
Solution 2:[2]
Try this on header.php for example, you can add sidebar where u want
if ( is_active_sidebar( 'Sidebar' ) ) {
dynamic_sidebar( 'Sidebar' );
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | LoicTheAztec |
Solution 2 | ?????? ??????? |