Right now I am adding a sidebar above my woocommerce products. How can I hook the sidebar to my theme.
Have registered sidebar and it works.
register_sidebar(
array(
'name' => __( 'Filters', 'woothemes' ),
'id' => 'filters',
'description' => __( 'Optional widgetized shop page (displays only if widgets are added here).', 'woothemes' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>'
)
);
This is the hook I have used without success.
add_action( 'woo_main_before', 'woo_sidebar' );
function woo_sidebar() {
if (is_woocommerce()) {
echo '<div class="primary">';
woo_sidebar( 'filters' );
echo '</div>';
}
*Update: Using the code below adds this widget area to all other widget areas. Example: In the footer of www.lne.net.au.
add_action( 'woo_main_before', 'woo_sidebar' );
function woo_sidebar() {
if (is_woocommerce()) {
echo '<div class="primary">';
dynamic_sidebar( 'filters' );
echo '</div>';
}
}
You should use the dynamic_sidebar to spit out the widgets inside the newly created sidebar before the woo main container.
This solution has been tested on a single product page using Woo Commerce.
This method works from your child themes functions.php file and is the suggested method for non developers who customize themes.
Here’s more about Woo’s conditional tags for Woo Commerce
You can change both the hook and conditional tag.
Note: If you don’t have a child theme created, you can use the Custom Functions section of any Woo themes functions file.
Yey! Finally found a solution, replacing the depreciated hook
woo_sidbar
withwoocommerce_sidebar
. Also replacingwoo_sidbar
withdynamic_sidebar
.Thank you everyone for your help. Muz