- This topic has 7 replies, 2 voices, and was last updated 6 years, 1 month ago by
Leo.
-
AuthorPosts
-
October 21, 2017 at 2:59 pm #407694
Robert
I’d like to add a custom sidebar to just the Woocommerce shop page. I created a new sidebar and tried to get it to show up on the woocommerce default shop page but alas, nothing. Any ideas? The sidebar is showing up under Widgets.
add_action( 'widgets_init', 'theme_slug_widgets_init' ); function theme_slug_widgets_init() { register_sidebar( array( 'name' => __( 'woo', 'woo' ), 'id' => 'woo', 'description' => __( 'Widgets in this area will be shown on all posts and pages.', 'woo' ), 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', ) ); } add_action( 'wp','tu_woocommerce_sidebar' ); function tu_woocommerce_sidebar() { if ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) { remove_action( 'generate_sidebars','generate_construct_sidebars' ); add_action( 'generate_sidebars','tu_construct_woocommerce_sidebar' ); } } function tu_construct_woocommerce_sidebar() { get_sidebar( 'woo' ); }
October 21, 2017 at 4:37 pm #407707Leo
StaffCustomer SupportHi there,
So I assume you are using sidebar already on other pages as well?
This plugin might be the easiest: https://en-ca.wordpress.org/plugins/content-aware-sidebars/
October 21, 2017 at 6:29 pm #407732Robert
Nope, I haven’t used this sidebar on any pages, I created it specifically for this one page.
October 21, 2017 at 9:13 pm #407758Leo
StaffCustomer SupportAhh if that’s the case, set the global setting to Content (No Sidebar): https://docs.generatepress.com/article/sidebar-layout/
Then turn it on for WooCommerce only: https://docs.generatepress.com/article/woocommerce-overview/#shop
Let me know.
October 22, 2017 at 10:30 am #408028Robert
Sorry, maybe I wasn’t clear. I am using sidebars throughout the site, but I would like to create a brand new one, specifically used for just the Woocommerce pages, and not use an existing one. I registered the new sidebar, the issue is having it show up only on the Woocommerce pages, as the default sidebar is currently showing.
October 22, 2017 at 11:12 am #408051Leo
StaffCustomer SupportHave you tried this plugin? https://en-ca.wordpress.org/plugins/content-aware-sidebars/
October 23, 2017 at 11:41 am #408634Robert
I haven’t. I was trying to avoid having to use a plugin and managing multiple widgets. I find it cleaner to do it by just creating a new sidebar and assigning it to a page but I guess that isn’t possible with this theme. Thanks.
October 23, 2017 at 11:53 am #408648Leo
StaffCustomer SupportNo problem!
-
AuthorPosts
- You must be logged in to reply to this topic.