Hi,
Is there any way I could have a sidebar in my woocommerce shop page without having a sidebar in global settings?
Thanks,
Darryn
Hi,
Is there any way I could have a sidebar in my woocommerce shop page without having a sidebar in global settings?
Thanks,
Darryn
Hi Darryn,
Please add the following code under functions.php
file locates in your child theme:
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 = 'content-sidebar';
} 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_shop() ) {
$layout = 'content-sidebar';
}
return $layout;
}
After that create the shop sidebar under Appearance > Sidebars:
Hope it helps
Hi Thai,
Very cool and much appreciation!
I am being a bit silly, how do I find the Woocommerce Taxonomy. I can’t seem to allocate this on my site?
Sorry Thai, please also see screenshot as the sidebar appears on the bottom right of my page? Also not sure what I have done wrong?
Thanks,
Darryn
Hi @bricmor,
Not sure what are you lacking. I could not verify what you did. In this case, please share us your admin credentials and FTP so we could check your setup further.
Don’t forget to set it in a secure note.
Thanks.
hi thanks Thai,just sent you details.
Hello There,
Since the sidebar setup is not added properly on the settings and just on the code, the following CSS is needed to for the code to work:
.woocommerce .x-main.left {
width: 70%; /*Main content width*/
}
.woocommerce aside.x-sidebar.right {
width: 28%; /*Sidebar width*/
padding-left: 2%; /*Space from content*/
}
Adjust values accordingly. That CSS will make room for the sidebar on the right part.
About this question: I am being a bit silly, how do I find the Woocommerce Taxonomy. I can't seem to allocate this on my site?
, can you clarify what you meant by this? I assume by that question, you also want to add the sidebar on woocommerce taxonomy pages. correct? If yes, on the code suggested, look for the following part at the bottom:
if ( x_is_shop() ) {
$layout = 'content-sidebar';
}
Update that code this:
if ( x_is_shop() || x_is_product_category() || x_is_product_tag() ) {
$layout = 'content-sidebar';
}
Hope this helps. Also note that maintenance of custom codes, and further customization is outside the scope of our support. For more customization we do suggest to consult a web developer. Thank you for understanding.
hi Lely,
thank you so much for all the assistance. just the last thing. how do i move the column to the left. i tried changing the css code.
apologies ,i normally use another theme which has custom sidebars on each page and am used to that theme so thought i would finally try x theme,but getting the hang of it… thanks for all your extra help,very much appreciated.
Hi there,
You can change it to sidebar-content
, it’s the positioning of sidebar and content.
And I understand what you’re saying, the theme is a framework made for customization both through options and code level. As it makes the theme limitless to what you can achieve once you familiarized it.
Thanks!
Thanks Rad,
Good to know. I just need that thing called “time”,but will give it another go.
Regards,
Darryn
On behalf of my colleague, you’re welcome. Cheers!
x_is_shop() || x_is_product_category() || x_is_product_tag() – works for standard product categories and tags, but not for custom taxonomies.
For example, I have a separate tag for products called “Nutrient Tags” – for things like gluten free, paleo inspired, etc.
I needed to use is_product_taxonomy, which you don’t currently have in your conditionals.php functions. It picks up all product tags and categories too.
Hello There,
Thanks for updating this thread. Regretfully there is no available is_product_taxonomy()
function. You might need to use other conditional statements provided by WooCommerce. Please check out this page:
Hope this helps.
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.