Does anyone know how I would set the woocommerce product category page (not the shop page) to include a left hand sidebar?
This was a question asked by a user in the Genesis support forum.
The code below will let you force a sidebar-content layout in the Genesis Framework, when a WooCommerce product category archive is displayed. If you need to force this layout on other taxonomies, simply change the condition.
<?php
/**
* Sidebar-Content Layout on Product category archives
*
* @author UltimateWoo <www.ultimatewoo.com>;
*/
function ultimatewoo_wc_product_cat_genesis_layout() {
if ( is_tax( 'product_cat' ) ) {
return 'sidebar-content';
}
}
add_filter( 'genesis_site_layout', 'ultimatewoo_wc_product_cat_genesis_layout' );
How would I do this on the right side instead of left side using a simple sidebar created with Genesis Simple Sidebars? I tried to change your code on the return line to specify my custom sidebar, but that didn’t work. It stayed on the left and it did not return my custom sidebar. It returned a default sidebar and then a secondary widget area below it.
Brian,
Even though your sidebar has its own ID, it doesn’t affect the layout. Therefore, you’ll need to change the layout identifier.
On line 10, change
sidebar-content
tocontent-sidebar
.Hmm okay it’s displaying on the right side now. Do you know how I can get my custom sidebar to show for all categories by default though? Currently I have to set it on each category which isn’t terrible, but I don’t want to add future categories and have to remember to change the sidebar. If I don’t change it then it gives me the primary sidebar instead of my custom sidebar. Thanks again.