Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #10491

    Athy G
    Participant

    Hi,
    I’m unable to find instructions to create a custom sidebar to display exclusively on my Woocommerce Shop page (to include product categories, product ratings, etc).
    I am using the ‘Integrity Stack’, which has a ‘Main Sidebar’ & this is displaying on all pages (including shop page). I don’t want to modify this sidebar, as I intend to use for all pages bar the Shop page. I have attempted to create a ‘new’ Sidebar via Appearance -> Sidebars, and assigned to the ‘Shop’ page, but this doesn’t work.
    Can you please advise the correct procedure to create a custom Shop sidebar?

    Thanks.

    #10502

    Kory
    Keymaster

    Hey Athy,

    Thanks for writing in! Currently, unique sidebars cannot be set for archive pages (i.e. the blog, portfolio, shop, et cetera), due to a few developmental nuances of how WordPress handles these “pages.” We are aware of this issue and are looking to address it in a coming release of the theme. For the time being, we can walk you through how to do this via a child theme if you’d like. If you do not yet have a child theme setup for your site, we have an in-depth article in the Knowledge Base that goes over how to do this. Once you have that in place, let us know and we can share with you how to accomplish this.

    Thanks!

    #10708

    Athy G
    Participant

    Hello again,

    Thanks for the feedback – I thought I might be missing something obvious.

    I have already created a child theme, so eagerly await further instructions.

    Thanks,
    Athy.

    #10787

    Kory
    Keymaster

    Hey Athy,

    I have just responded to your previous post and after reviewing your site and providing you with a solution for your thumbnails; however, I see that you do not have a sidebar activated on your shop page anymore. Let me know if you still want to move forward on this request as it appears that you have opted for a fullwidth shop page instead.

    Thanks!

    #10830

    Athy G
    Participant

    Hi,
    I’m still interested in adding a custom sidebar to the shop page. I’d be grateful if you could provide instructions for implementing this.

    Thanks.

    #11087

    Kory
    Keymaster

    Hey Athy,

    You’ll need to add the following code to your functions.php file in your child theme first:

    function x_my_custom_widgets_init() {
    
      register_sidebar( array(
        'name'          => __( 'My Shop Sidebar', '__x__' ),
        'id'            => 'sidebar-my-custom-shop',
        'description'   => __( 'Appears on the index shop page.', '__x__' ),
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget'  => '</div>',
        'before_title'  => '<h4 class="h-widget">',
        'after_title'   => '</h4>',
      ) );
    
    }
    
    add_action( 'widgets_init', 'x_my_custom_widgets_init' );

    Then you’ll need to update the /framework/views/integrity/wp-sidebar.php file from your parent theme by copying it to your child theme and modifying the markup. Once you have copied the file over correctly by following the instructions in the Knowledge Base article above, you will need to update this file’s output with the following markup:

    <?php
    
    // =============================================================================
    // VIEWS/INTEGRITY/WP-SIDEBAR.PHP
    // -----------------------------------------------------------------------------
    // Sidebar output for Integrity.
    // =============================================================================
    
    ?>
    
    <?php
    
    $blog_layout      = get_theme_mod( 'x_blog_layout' );
    $archive_layout   = get_theme_mod( 'x_archive_layout' );
    $shop_layout      = get_theme_mod( 'x_woocommerce_shop_layout_content' );
    $portfolio_layout = get_theme_mod( 'x_portfolio_layout' );
    $main_layout      = get_theme_mod( 'x_integrity_layout_content' );
    
    if ( $main_layout != 'full-width' ) {
      if ( is_home() ) {
        $layout = $blog_layout;
      } elseif ( is_archive() ) {
        if ( is_post_type_archive( 'x-portfolio' ) ) {
          $layout = $portfolio_layout;
        } elseif ( function_exists( 'is_shop' ) && is_shop() ) {
          $layout = $shop_layout;
        } else {
          $layout = $archive_layout;
        }
      } elseif ( function_exists( 'is_product' ) && is_product() ) {
        $layout = 'full-width';
      } else {
        $layout = $main_layout;
      }
    } else {
      $layout = $main_layout;
    }
    
    ?>
    
    <?php if ( is_page_template( 'template-layout-content-sidebar.php' ) ) : ?>
    
      <aside class="x-sidebar right" role="complementary">
        <?php if ( get_option( 'ups_sidebars' ) != array() ) : ?>
          <?php dynamic_sidebar( apply_filters( 'ups_sidebar', 'sidebar-main' ) ); ?>
        <?php else : ?>
          <?php dynamic_sidebar( 'sidebar-main' ); ?>
        <?php endif; ?>
      </aside>
    
    <?php elseif ( is_page_template( 'template-layout-sidebar-content.php' ) ) : ?>
    
      <aside class="x-sidebar left" role="complementary">
        <?php if ( get_option( 'ups_sidebars' ) != array() ) : ?>
          <?php dynamic_sidebar( apply_filters( 'ups_sidebar', 'sidebar-main' ) ); ?>
        <?php else : ?>
          <?php dynamic_sidebar( 'sidebar-main' ); ?>
        <?php endif; ?>
      </aside>
    
    <?php elseif ( function_exists( 'is_shop' ) && is_shop() ) : ?>
    
      <aside class="x-sidebar left" role="complementary">
        <?php dynamic_sidebar( 'sidebar-my-custom-shop' ); ?>
      </aside>
    
    <?php elseif ( $layout != 'full-width' ) : ?>
    
      <aside class="<?php x_integrity_sidebar_class(); ?>" role="complementary">
        <?php if ( get_option( 'ups_sidebars' ) != array() ) : ?>
          <?php dynamic_sidebar( apply_filters( 'ups_sidebar', 'sidebar-main' ) ); ?>
        <?php else : ?>
          <?php dynamic_sidebar( 'sidebar-main' ); ?>
        <?php endif; ?>
      </aside>
    
    <?php endif; ?>

    After you have done this, you can add widgets to your sidebar widget area for your shop under Appearance > Widgets in the admin area.

    Thanks!

    #11157

    Athy G
    Participant

    Great – thanks for that….worked a treat 🙂

    #11160

    Athy G
    Participant

    I wonder if you could help me with another issue I’m having as I’ve had no luck implementing the solution proposed. I’m trying to achieve size consistency with my shop products, here’s the thread:
    http://theme.co/x/member/forums/topic/shop-product-size-inconsistencies/#post-11082

    I have tried to follow the instructions provided, but it caused a fatal error, so had to restore the functions.php file. Can you please advise how to make this correction?

    Thanks,
    Athy.

    #11164

    Kory
    Keymaster

    Hey Athy,

    Glad to hear it’s working! 🙂

    Regarding your other request, as I stated in that post simply replace x_integrity_post_thumbnail_width() in the add_image_size() function with a number for how wide you’d like your images to be.

    Thanks!

    #11984

    Athy G
    Participant

    Hello again,

    Managed to get this sorted for the main shop page, but still having issues with this, ie:
    – Products page – no sidebar appearing on this page
    – Categories page – wrong sidebar appearing (standard, rather than custom Woocommerce).

    Seems there’s still a bit of work to get this sorted.

    Athy.

    #11993

    Kory
    Keymaster

    Hey Athy,

    X does not currently support sidebars on product pages. If you want this, you will need to make the same adjustments outlined in this post in your child theme.

    Are you planning on using your main sidebar or a blog at all on your site? If not, I would recommend just filling out the main sidebar with the same widgets as your shop sidebar that we setup and that will work for you. If this doesn’t work for you, let us know and we can help you get this setup. Having the shop sidebar appear on your category pages was not specified in the original post which is why we did not include it in our solution.

    Thanks.

    #92721

    Maria V
    Participant

    Hello, I had the same problem than Athy. I wanted to have a sidebar in my shop that wasn’t the main one. I followed the instructions provided and it works nicely but now the sidebar content has disappeared from all the other pages, the main bar and also an extra one I created. The space just appears blank. Could you help me with this? Thank you

    #92876

    Christian
    Moderator

    Hey Maria,

    In that case, please give us access to your WordPress admin so we could see your setup in the back-end.

    Thanks.

    #93342

    Maria V
    Participant

    Hello again, I’m working on my site on local, I haven’t uploaded yet. Any tips or ideas on what I should check? Thank you very much

    #93457

    Mrinal
    Member

    Hi Maria,

    This post is too old, so the given solution won’t work with latest theme versions. Please create a new fresh thread your own then tell us your problem there.

    Have a nice day, Cheers!