Tagged: x
-
AuthorPosts
-
January 25, 2017 at 3:40 pm #1345306
Philip MParticipantHi,
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.
January 25, 2017 at 8:12 pm #1345708
NicoModeratorHi 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.
January 26, 2017 at 2:51 am #1346015
Philip MParticipantHi,
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.January 26, 2017 at 3:37 am #1346066
LelyModeratorHello 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.
January 26, 2017 at 7:00 am #1346241
Philip MParticipantHello 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.January 26, 2017 at 7:01 am #1346242
Philip MParticipantThis reply has been marked as private.January 26, 2017 at 8:07 am #1346314
LelyModeratorHello 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.
January 26, 2017 at 8:20 am #1346325
Philip MParticipantHi,
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.January 26, 2017 at 8:51 am #1346372
LelyModeratorHello 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!
January 27, 2017 at 4:19 am #1347555
Philip MParticipantThanks again Lely,
you’re a star.
Regards,
Philip.January 27, 2017 at 4:43 am #1347575
LelyModeratorYou’re welcome Philip!
Cheers!
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1345306 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
