Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1345306
    Philip M
    Participant

    Hi,
    as above. I know this has been discussed a lot, but there seems to be many different solutions for different situations.

    However, I found an answer that seems to be exactly what I need – https://community.theme.co/forums/topic/sidebar-on-single-product-page-7/

    My problem is, in the instructions on how to acheive it, specifically “Please create a sidebar via Appearance > Sidebars. You can select it to only appear on product pages.” I can create a new sidebar no problem, but I can’t see where to have it show on product pages. Everywhere else yes, but not on product pages.

    Could you please enlighten me?

    Thanks again for all your help.

    #1345708
    Nico
    Moderator

    Hi There,

    First, we need to check your setup so that we could see what did you miss.

    Please share us your admin credentials in private reply.

    Meanwhile, you could follow the link below about sidebars:

    https://community.theme.co/kb/unlimited-sidebars/

    Hope it helps.

    Thanks.

    #1346015
    Philip M
    Participant

    Hi,
    I don’t think I missed anything, everything is straightforward, as per the link.

    I’m just asking, what term do I actually select out of the 2 lists on the left of the Manage Sidebars form (All Pages and Posts / All Taxonomies) to get it to show on the single product page?

    Thanks again,
    Philip.

    #1346066
    Lely
    Moderator

    Hello Philip,

    To achieve that we need to add the following code on your child theme style.css file:

    To display sidebar on single product page:

     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_product() ) {
    				$layout = 'content-sidebar';
    		}
        return $layout;
    
      }

    To display custom sidebar. Replace ups-sidebar-cat-sidebar with your own custom sidebar ID.

    add_filter( 'ups_sidebar', 'product_sidebar', 9999 );
    
    function product_sidebar ( $default_sidebar ) {
    if ( x_is_product() ) return 'ups-sidebar-cat-sidebar'; //Must match the ID of your target sidebar
    return $default_sidebar;
    }

    Hope this helps.

    #1346241
    Philip M
    Participant

    Hello Lely,
    many thanks for all that, but unfortunately, it hasn’t made any difference.

    Is there something else I need to do as well, or is that everything above?

    I will put log in deetails below just incase.

    Thank you,
    Philip.

    #1346242
    Philip M
    Participant
    This reply has been marked as private.
    #1346314
    Lely
    Moderator

    Hello Philip,

    Thank you for the credentials.
    I made a mistake on my previous instruction. It should be added instead on your child theme’s functions.php file. I have remove it from style.css file and move it functions.php file. The sidebar is now showing. See this:http://screencast-o-matic.com/watch/cbVO2hQMWw. We’re sorry for the inconvenience.

    Hope this helps.

    #1346325
    Philip M
    Participant

    Hi,
    thanks, I see it.

    I know I didn’t specifically say this, but I expected it to be on the left hand side, the same as the other sidebars. Sorry about not being clearer about that.
    Would it take much to change it?

    Thanks again,
    Philip.

    #1346372
    Lely
    Moderator

    Hello Philip,

    Look for this part of the code:

    if ( x_is_product() ) {
    	$layout = 'content-sidebar';
    }

    Update to this:

    if ( x_is_product() ) {
    	$layout = 'sidebar-content';
    }

    Cheers!

    #1347555
    Philip M
    Participant

    Thanks again Lely,
    you’re a star.
    Regards,
    Philip.

    #1347575
    Lely
    Moderator

    You’re welcome Philip!

    Cheers!

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