-
AuthorPosts
-
December 18, 2014 at 8:10 am #167030
gretarParticipantHello
I have been trying to set a sidebar to my single Woocommerce product page, example here, http://trsnyr.endor.is/netverslun/lenovo-yoga-2-pro-13-3-spjaldtolva-32gb-android/ but the other threads in the forum with custom code for functions.php do not work.
Any chance I can get help with this ?
December 18, 2014 at 8:21 pm #167380
Nabeel AModeratorHi Gretar,
Can you please share the code you’re trying for the sidebar with us, may be we can help you fixing it for your site.
Thanks!
December 19, 2014 at 2:31 am #167485
gretarParticipantThis is the code
if ( ! function_exists( 'x_get_content_layout' ) ) : function x_get_content_layout() { $stack = x_get_stack(); $content_layout = x_get_option( 'x_' . $stack . '_layout_content', 'content-sidebar' ); if ( $content_layout != 'full-width' ) { if ( is_home() ) { $opt = x_get_option( 'x_blog_layout', 'sidebar' ); $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() || x_is_product() ) { $opt = x_get_option( 'x_woocommerce_shop_layout_content', 'sidebar' ); $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt; } else { $opt = x_get_option( 'x_archive_layout', 'sidebar' ); $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt; } } elseif ( x_is_bbpress() ) { $opt = x_get_option( 'x_bbpress_layout_content', 'sidebar' ); $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt; } elseif ( x_is_buddypress() ) { $opt = x_get_option( 'x_buddypress_layout_content', 'sidebar' ); $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt; } elseif ( is_404() ) { $layout = 'full-width'; } else { $layout = $content_layout; } } else { $layout = $content_layout; } return $layout; } endif;December 19, 2014 at 3:38 pm #167871
RadModeratorHi there,
The code will only enable the layout with sidebar, there is another code that must display the sidebar.
Add this code at along with that,
add_filter( 'ups_sidebar', 'woocommerce_sidebar', 9999 ); function woocommerce_sidebar ( $default_sidebar ) { $sidebars = get_option( 'ups_sidebars' ); foreach ( $sidebars as $id => $sidebar ) { if ( x_is_shop() || x_is_product_category() || x_is_product_tag() || x_is_product() ) { if ( array_key_exists( 'index-shop', $sidebar ) && $sidebar['index-shop'] == 'on' ) { return $id; } } } return $default_sidebar; }It will use the sidebar you set at Admin > Appearance > Sidebars that is set for Shop index.
Then add your widgets at Admin > Appearance > Widgets.
Hope this helps.
December 22, 2014 at 2:18 am #168676
gretarParticipantCan you tell me exactly where to have this code with the other code because when I add this to the functions.php file I only get a blank white screen on my site…
December 22, 2014 at 2:31 am #168693
gretarParticipantSorry, I was missing the last } in the code 🙂
But the sidebar is still not showing on a single product page. I added a new sidebar with the name Vara and some widgets to it…
December 22, 2014 at 7:55 am #168886
ZeshanMemberHi Gretar,
Thanks for writing in!
In that case, would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / password
– FTP credentialsDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
Thanks!
December 22, 2014 at 8:25 am #168907
gretarParticipantThis reply has been marked as private.December 22, 2014 at 11:57 am #169047
ZeshanMemberHi Gretar,
Thank you for the WordPress credentials!
The FTP login is necessary to check the backend files, unfortunately, we cannot provide our IP address as we’re working from different locations.
Meanwhile, you could try following this thread: https://theme.co/x/member/forums/topic/no-sidebar-in-woocommerce/#post-167286
Thanks!
December 23, 2014 at 2:20 am #169614
gretarParticipantI added this code to functions.php
if ( ! function_exists( 'x_get_content_layout' ) ) : function x_get_content_layout() { $stack = x_get_stack(); $content_layout = x_get_option( 'x_' . $stack . '_layout_content', 'content-sidebar' ); if ( $content_layout != 'full-width' ) { if ( is_home() ) { $opt = x_get_option( 'x_blog_layout', 'sidebar' ); $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_archive() ) { if ( x_is_shop() || x_is_product_category() || x_is_product_tag() || x_is_product() ) { $layout = 'content-sidebar'; } else { $opt = x_get_option( 'x_archive_layout', 'sidebar' ); $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt; } } elseif ( x_is_product() ) { $layout = 'content-sidebar'; } elseif ( x_is_bbpress() ) { $opt = x_get_option( 'x_bbpress_layout_content', 'sidebar' ); $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt; } elseif ( x_is_buddypress() ) { $opt = x_get_option( 'x_buddypress_layout_content', 'sidebar' ); $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt; } elseif ( is_404() ) { $layout = 'full-width'; } else { $layout = $content_layout; } } else { $layout = $content_layout; } if ( 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'; } return $layout; } endif; add_filter( 'ups_sidebar', function ( $default_sidebar ) { $sidebars = get_option( 'ups_sidebars' ); foreach ( $sidebars as $id => $sidebar ) { if ( x_is_shop() || x_is_product_category() || x_is_product_tag() || x_is_product() ) { if ( array_key_exists( 'index-shop', $sidebar ) && $sidebar['index-shop'] == 'on' ) { return $id; } } } return $default_sidebar; }, 9999 );But that did not work.
Can’t you give me 1 IP address from you that you try to connect with ? The backend files should be alright, I have not edited them. I can also see that there is a new version of your theme out now. I will update the theme.
December 23, 2014 at 7:04 am #169806
Paul RModeratorHi Gretar,
Sorry that you are still having issues.
You can try the code below, I have tested it in my local test site and it should work.
function x_get_content_layout() { $stack = x_get_stack(); $content_layout = x_get_option( 'x_' . $stack . '_layout_content', 'content-sidebar' ); if ( $content_layout != 'full-width' ) { if ( is_home() ) { $opt = x_get_option( 'x_blog_layout', 'sidebar' ); $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_archive() ) { if ( x_is_shop() || x_is_product_category() || x_is_product_tag() || x_is_product() ) { $layout = 'content-sidebar'; } else { $opt = x_get_option( 'x_archive_layout', 'sidebar' ); $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt; } } elseif ( x_is_product() ) { $layout = 'content-sidebar'; } elseif ( x_is_bbpress() ) { $opt = x_get_option( 'x_bbpress_layout_content', 'sidebar' ); $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt; } elseif ( x_is_buddypress() ) { $opt = x_get_option( 'x_buddypress_layout_content', 'sidebar' ); $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt; } elseif ( is_404() ) { $layout = 'full-width'; } else { $layout = $content_layout; } } else { $layout = $content_layout; } if ( 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'; } return $layout; } add_filter( 'ups_sidebar', function ( $default_sidebar ) { $sidebars = get_option( 'ups_sidebars' ); foreach ( $sidebars as $id => $sidebar ) { if ( x_is_shop() || x_is_product_category() || x_is_product_tag() || x_is_product() ) { if ( array_key_exists( 'index-shop', $sidebar ) && $sidebar['index-shop'] == 'on' ) { return $id; } } } return $default_sidebar; }, 9999 );Hope that helps.
December 23, 2014 at 8:43 am #169891
gretarParticipantYes ! The sidebar appears now but it’s on the right side of the page on a single product. My site has the sidebar on the left on other pages, I would like that to be the same on single product, what do I need to change ?
December 23, 2014 at 8:53 am #169907
gretarParticipantWell, suddenly the sidebar on all pages is on the right now… I would like to have it on the left side of the page.
December 23, 2014 at 10:33 am #170005
ChristopherModeratorHi there,
Please try this code:
function x_get_content_layout() { $stack = x_get_stack(); $content_layout = x_get_option( 'x_' . $stack . '_layout_content', 'content-sidebar' ); if ( $content_layout != 'full-width' ) { if ( is_home() ) { $opt = x_get_option( 'x_blog_layout', 'sidebar' ); $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_archive() ) { if ( x_is_shop() || x_is_product_category() || x_is_product_tag() || x_is_product() ) { $layout = 'sidebar-content'; } else { $opt = x_get_option( 'x_archive_layout', 'sidebar' ); $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt; } } elseif ( x_is_product() ) { $layout = 'sidebar-content'; } elseif ( x_is_bbpress() ) { $opt = x_get_option( 'x_bbpress_layout_content', 'sidebar' ); $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt; } elseif ( x_is_buddypress() ) { $opt = x_get_option( 'x_buddypress_layout_content', 'sidebar' ); $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt; } elseif ( is_404() ) { $layout = 'full-width'; } else { $layout = $content_layout; } } else { $layout = $content_layout; } if ( is_page_template( 'template-layout-content-sidebar.php' ) ) { $layout = 'sidebar-content'; } elseif ( is_page_template( 'template-layout-sidebar-content.php' ) ) { $layout = 'sidebar-content'; } elseif ( is_page_template( 'template-layout-full-width.php' ) ) { $layout = 'full-width'; } return $layout; } add_filter( 'ups_sidebar', function ( $default_sidebar ) { $sidebars = get_option( 'ups_sidebars' ); foreach ( $sidebars as $id => $sidebar ) { if ( x_is_shop() || x_is_product_category() || x_is_product_tag() || x_is_product() ) { if ( array_key_exists( 'index-shop', $sidebar ) && $sidebar['index-shop'] == 'on' ) { return $id; } } } return $default_sidebar; }, 9999 );Hope it helps.
December 29, 2014 at 4:24 am #172603
gretarParticipantYes, thank you ! The sidebar is on the left now.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-167030 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
