Trying to add a Product Filter on shop pages

Hi Friends,
We’re looking forward to launch day and are nearly there, but having difficulty trying to figure out how to add a product filter sidebar on the left of the product page (http://159.203.166.174/products/)


I found the following snippet on another page in the KB that got me a sidebar, but it’s stuck on the bottom right, whereas we’d like it on the left side and to travel down the page with scrolling.

// Add sidebar to product category and product pages
// =============================================================================
function x_woocommerce_sidebar($sidebar){
if ( x_is_product() || x_is_product_category() ) {
$contents = ‘content-sidebar’;
}

return $contents;
}
add_filter(‘x_option_x_layout_content’, ‘x_woocommerce_sidebar’);
// =============================================================================


I’ve tried a bunch of techniques but I can’t figure out how to get the sidebar on my woo pages. Any tips you can offer would be greatly appreciated.
Best wishes,
Andy

Hello @taotaoli,

Thanks for writing in! :slight_smile:

Please take a look at this tutorial on how to create sidebars and make sure the steps have been followed: Unlimited Sidebars

Then install this WP plugin: https://wordpress.org/plugins/php-code-widget/

When this has been installed, please go to Appearance > Widgets and insert PHP code widget
to your sidebar.

After that, please add this code into PHP code widget:

<?php
// Add sidebar to product category and product pages
// =============================================================================
function x_woocommerce_sidebar($sidebar){
if ( x_is_product() || x_is_product_category() ) {
$contents = 'content-sidebar';
}

return $contents;
}
add_filter('x_option_x_layout_content', 'x_woocommerce_sidebar');

?>

Hope it helps.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.