Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialernestinembak
272 PointsHi, would you please help finding where/how to override the sidebar on the archive page with a custom one?
Hi, I need to remove the automatically generated sidebar (get_sidebar( 'shop')) and replace it with my own sidebar
3 Answers
oxanaox
16,295 PointsHi, Is this sidebar
<?php get_sidebar( 'shop'); ?>
in your archive.php file? If yes, you need to replace it with your own sidebar, like
<?php get_sidebar ('custom'); ?>
and you have to register your custom sidebar in functions.php in your theme-folder with the following:
<?php if ( function_exists ('register_sidebar')) {
register_sidebar ('custom');
} ?>
Please note, that the file name of your custom sidebar should be sidebar-custom.php You can also refer to this documentation on Wordpress Codex about custom sidebars: here
Hope it helps.
Damian Reilly
Courses Plus Student 4,533 PointsYou may want to consider using the is archive conditional tag. For example:
<?php if( !is_archive() ) : ?>
<?php get_sidebar('shop'); ?>
<?php else : ?>
<?php get_sidebar ('custom'); ?>
<?php endif; ?>
ernestinembak
272 Pointswhere? on functions.php? Thanx
Damian Reilly
Courses Plus Student 4,533 PointsHi Ernestine,
Inside your theme folder, once you create a new widget area in your function.php file , go to your sidebar.php file and try adding the following code:
<?php if ( is_woocommerce() ) : ?>
<div id="primary" class="widget-area">
<div class="xoxo">
<?php dynamic_sidebar( 'name-of-your-widget-area' ); ?>
</div>
</div>
<?php else : ?>
<div id="primary" class="widget-area">
<div class="xoxo">
<?php dynamic_sidebar( 'woo' ); ?>
</div>
</div>
<?php endif; ?>
ernestinembak
272 Pointsernestinembak
272 PointsHi there thank for your answers... Maybe more details could explain what i'm really looking for...
I've set up a wordpress page and i'm trying to display products from woocommerce (via archive-product). everything ok so far...
But it seems like woocommerce is generating his own sidebar which I need to replace with a custom one. Here the automaticcally generated sidebar: http://www.tecbuima.com/catalogue/ Here the one I need to be displayed: http://www.tecbuima.com
I unsuccessfully tried to update the sidebar.php from woocommerce get_sidebar( 'shop' ); ?> to custom one get_sidebar( 'woo' ); ?> but nothing happens
also tried to remove the hook .. do_action( 'woocommerce_sidebar' ); ... from archive-product.php and replace by a new one.... does not work as well
Moreover, I could not find the automatically generated "shop" sidebar in woocommerce....
so... hope this will help you to help me...
thanks in advance