Tagged: x
-
AuthorPosts
-
May 20, 2016 at 10:03 am #1001628
frix00ParticipantHi,
We’d like to have the sidebar displayed on the left hand side when users are in the Shop (WooCommerce) section, but have it on the right hand side in the Blog section.
Currently, the theme customiser offers only one radio buttion option to have “content left, side bar right” or “content right, sidebar left” and o option to set this only for the Blog, or only for the Shop.We also have two different sidebars for these two sections: the Shop uses the normal main sidebar, with widgets related to commerce (product filters, etc) while the Bolg has its own Sidebar, with widgets such as latest posts, etc.
See URLs :
https://www.vinoa.co.uk/shop/
https://www.vinoa.co.uk/magazine/Is there a simple way of handling this via some code in functions.php (or elsewhere) ?
Thanks !
Greg
May 20, 2016 at 12:05 pm #1001817
RahulModeratorHi Greg,
I see, please add this code at your child theme’s functions.php
if ( ! function_exists( 'x_get_content_layout' ) ) : function x_get_content_layout() { $content_layout = x_get_option( 'x_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() ) { $layout = 'sidebar-content'; } else { $layout = 'sidebar-content'; } } 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; } return $layout; } endif;Then just set your sidebar to right, and the code will handle the shop sidebar to left.
Thanks!
May 23, 2016 at 11:41 am #1005520
frix00ParticipantAmazing – that’s almost perfect. It works in getting me the side bar on the right on individual posts, but on the category landing pages, the sidebar is still on the left – any ideas ?
Thanks
Greg
May 23, 2016 at 11:45 am #1005529
frix00ParticipantNot to worry, I edited your code to add
elseif ( is_category(‘magazine’) ) {
$layout = ‘content-sidebar’;
}May 23, 2016 at 11:46 am #1005530
frix00ParticipantThanks a lot !!
May 23, 2016 at 11:46 am #1005535
JoaoModeratorYou are welcome.
Let us know if you need help with anything else.
Joao
June 1, 2016 at 3:13 pm #1020750
jclay12345ParticipantI just tried this and it worked for me, but now my product pages have a sidebar and I would like those to be full width. Any ideas?
I tried editing this line
elseif ( x_is_product() ) { $layout = 'sidebar-content'; }to
elseif ( x_is_product() ) { $layout = 'full-width'; }but that doesn’t seem to work
June 1, 2016 at 3:42 pm #1020805
jclay12345ParticipantSorry, that change worked. it must’ve been a problem with caching.
June 1, 2016 at 10:00 pm #1021384
FriechModeratorCool, should you require any further assistance with X|THEME and Cornerstone, please feel free to get in touch with us.
Cheers!
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1001628 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
