Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1045541
    Eric M
    Participant

    when connecting a custom sidebar to a certain page, you select that page on the sidebar page. Im trying to do the same for each product in an eCommerce store but not seeing where to select the product. Am i missing something?

    #1045676
    Rupok
    Member

    Hi there,

    You can’t select for individual products. Custom sidebars will work for pages, posts and taxonomies. For others, the main sidebar will be used.

    Cheers!

    #1052524
    Eric M
    Participant

    So ive followed the instructions on this page: https://community.theme.co/forums/topic/sidebar-in-single-product-page-woocommerce/

    What do i change to tell which product ID i want the sidebar to appear on?

    #1053095
    Nico
    Moderator

    Hi There,

    Not sure if the code is still working because the thread is quite from the past date already.

    It is quite a custom code and it beyond the scope of our support however I could guide you a bit of what to change.

    You need to modify this code in the thread to make it specific for a product page.

    add_filter( 'ups_sidebar', 'product_sidebar', 9999 );
    
    function product_sidebar ( $default_sidebar ) {
    
      $sidebars = get_option( 'ups_sidebars' );
    
      foreach ( $sidebars as $id => $sidebar ) {
        if ( x_is_product() ) {
          if ( array_key_exists( 'index-shop', $sidebar ) && $sidebar['index-shop'] == 'on' ) {
            return $id;
          }
        }
      }
    
      return $default_sidebar;
    
    }

    Hope it helps.

    Thank you so much for understanding.

    #1054539
    Eric M
    Participant

    but what part is calling the single product?

    #1055251
    Rad
    Moderator

    Hi Eric,

    This condition if ( x_is_product() ), and if you wish to make it more specific to product page then you can do something like this,

    if ( x_is_product() && is_single( 923 ) ) {

    Where 923 is the product ID. Or if you wish a condition with multiple ID, then it can be like this,

    if ( x_is_product() && is_single( array( 923, 924, 925 ) ) ) {

    Hope that helps.

    #1062277
    Eric M
    Participant

    awesome thanks.

    #1062639
    Nico
    Moderator

    Happy to hear that.

    Feel free to ask us again.

    Thanks.

  • <script> jQuery(function($){ $("#no-reply-1045541 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>