Side bar on Category, Shop, Product pages

Hi, I’m trying to add a side bar to my woocommerce site. I’d like it to show on all of the woocommerce pages but not the other pages (resource, news, class schedules, etc). I added code to my functions.php file that I found in a post from a few years ago but it isn’t showing up correctly. Any help would be greatly appreciated! Here is the code I added:

function x_get_content_layout() {

    $content_layout = x_get_option( 'x_layout_content' );

    if ( $content_layout != 'full-width' ) {
      if ( is_home() ) {
        $opt    = x_get_option( 'x_blog_layout' );
        $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
      } elseif ( is_singular( 'post' ) ) {
        $meta   = get_post_meta( get_the_ID(), '_x_post_layout', true );
        $layout = ( $meta == 'on' ) ? 'full-width' : $content_layout;
      } elseif ( x_is_portfolio_item() ) {
        $layout = 'full-width';
      } elseif ( x_is_portfolio() ) {
        $meta   = get_post_meta( get_the_ID(), '_x_portfolio_layout', true );
        $layout = ( $meta == 'sidebar' ) ? $content_layout : $meta;
      } elseif ( is_page_template( 'template-layout-content-sidebar.php' ) ) {
        $layout = 'content-sidebar';
      } elseif ( is_page_template( 'template-layout-sidebar-content.php' ) ) {
        $layout = 'sidebar-content';
      } elseif ( is_page_template( 'template-layout-full-width.php' ) ) {
        $layout = 'full-width';
      } elseif ( is_archive() ) {
        if ( x_is_shop() || x_is_product_category() || x_is_product_tag() ) {
          $opt    = x_get_option( 'x_woocommerce_shop_layout_content' );
          $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
        } else {
          $opt    = x_get_option( 'x_archive_layout' );
          $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
        }
      } elseif ( x_is_product() ) {
        $layout = 'full-width';
      } elseif ( x_is_bbpress() ) {
        $opt    = x_get_option( 'x_bbpress_layout_content' );
        $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
      } elseif ( x_is_buddypress() ) {
        $opt    = x_get_option( 'x_buddypress_layout_content' );
        $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
      } elseif ( is_404() ) {
        $layout = 'full-width';
      } else {
        $layout = $content_layout;
      }
    } else {
      $layout = $content_layout;
    }
     if ( x_is_shop() || x_is_product_category() || x_is_product_tag() ) {
         $layout = 'content-sidebar';
     }
    return $layout;

  }

Hello Susan,

Thank you for a very detailed post information. I have logged in and checked your site. I found out that the homestore, cart and my-account page is using Blank - Container | Header, Footer page templates. This is why there is no sidebar on these pages. If you want to display the sidebar, please change the page template to just default template. For more details about the different page templates in the theme, please check this out:

We would love to know if this has worked for you. Thank you.

Thank you so much for getting back to me. Not sure what happened, but all the pages (including the category, single product, and shop pages) now have the sidebar, but they are all at the bottom of the page and show the settings for the sidebar rather than the sidebar items. The sidebar is also now on all pages, including the main site pages (Home, classes, resources, news, etc). I really don’t want it on those pages. Any ideas on this? I appreciate your time!

Hello Susan,

I am not seeing a sidebar in the mentioned pages.

Please see the secure notes.

Hi Ruenel,

If you scroll past the footer on any page you will see the sidebar settings in a box labeled “Sidebar Infos”. Also, on the cart page, the same sidebar is on the bottom but it also has a sidebar on the left where I want it on the cat, shop, and product pages but it too has the settings rather than the widgets.
The shop page has the start of a sidebar on the left just under the header with “ups-sidebar-shop” in it.

I really do appreciate this!

Hello Susan,

That is actually not an issue. Those things appeared because you have turn ON the Sidebar Debug from Custom Sidebars plugin.

K5THBkqzT1CC-IhUN9izAA

You will need to turn it OFF or deactivate the Custom Sidebar plugin instead.

Best Regards.

Thank you. It is gone. But the problem of no sidebars remains. The only page with a sidebar is the cart page. I really need it to be on the shop, category, and product pages as well. I can’t find a way of changing the template for those pages and the php file I added (if I added it correctly) doesn’t seem to make a difference. Any ideas?

Hi Susan,

Great, it now resolves for other pages.

To get the sidebar in the shop & product category pages you need to set the widget in Shop 3 Widget area.

In the HomeStore page, the page template selected without the sidebar. Please select any sidebar template with sidebar options.

Hope it helps.

Thanks

THANK YOU!!! It worked! Is there a way to make the sidebar be on the left on the category and product pages like it is on the cart page? Do you know if there is a “product tag” widget other than the tag cloud? I’d like to display them as a drop down like the product categories.

I know this is a different topic, but I’ve also been trying to reduce the font size of the product names that appear under the images of the products on the category and product pages. Do you know how I can change that?

Thank you so much, both of you!

Sorry, I thought the problem went away, but its back. On the shop page, the sidebar pops up when you scroll down the page a little but disappears when you scroll back to the top. Is there a way of fixing this?

Thanks!

Hi Susan,

In Your Shop page we found that the Logo font size is actually the cause of the issue. We tested by decrasing the size by 2px and it works. You can use the following code to reduce the size.

.x-brand
{
    font-size:28px;
}

Remember that the above code will work if copied as it is and don’t conflict with any existing style.
To get more help on that please go through resource.
Please note that the code provided serves only as a guide to help you get started custom coding on your own if there’s no option offered in our theme or the products we bundle. We do not provide support for custom codes that means we can’t fix it in case it conflicts with something in your site nor will we enhance it.

Hope it helps.

Thanks

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