WPIntell

Source evidence

Custom sidebars for Wocoommerce categories

Ocean Custom Sidebar · support · 2021-07-07T06:44:00+00:00

complaintsentiment
mediumseverity
0.93relevance
7replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

3 / 32 rows with source links

9.4% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

29 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
lamayas unresolved
Hello, I would like to have different sidebars for my Woocommerce category. How can I assign them to each category? Thanks in advance! Hello, Please create a new sidebar using the ocean custom sidebar plugin and add the widgets as per your need. Add the below code in the functions.php file of your child theme. function prefix_cpt_sidebar( $sidebar = 'sidebar' ) { if ( is_category( 'YOUR CATEGORY NAME HERE' ) ) { $sidebar = 'your-sidebar-id'; } return $sidebar; } add_filter( 'ocean_get_sidebar', 'prefix_cpt_sidebar' ); PS- Replace the sidebar id with your own and YOUR CATEGORY NAME HERE. You can also use conditional tags according to need. https://codex.wordpress.org/Conditional_Tags Hi Abhishek, The code didn’t work, the default Woocommerce sidebar is still displaying on the category. Here’s the code in case I missed something: function prefix_cpt_sidebar( $sidebar = 'sidebar' ) { if ( is_category( 'red-wine' ) ) { $sidebar = 'ocs-red-wine'; } return $sidebar; } add_filter( 'ocean_get_sidebar', 'prefix_cpt_sidebar' ); Thanks for your help. Hello, Please try to clear the cache and check. Kindly share the page URL where you are trying this and also share the snapshot of your sidebar settings/name. Hi again, the site is in development so I don’t have any cache plugin installed yet. Here are the screenshots so you can have a better look: Sidebar: https://www.awesomescreenshot.com/image/10610730?key=239d35ccfb57a9579666b39e9cdff584 Widgets: https://www.awesomescreenshot.com/image/10610922?key=93007ced9373fae6be4b04e2cb94cd96 Category page: https://www.awesomescreenshot.com/image/10611227?key=261b68f325ef8851d69651f6adfef7c3 Hello, Thank you for sharing teh snapshots, Kindly try the below code and check. function prefix_cpt_sidebar( $sidebar = 'sidebar' ) { if ( is_category( 'red-wine' ) ) { $sidebar = 'Red Wine'; } return $sidebar; } add_filter( 'ocean_get_sidebar', 'prefix_cpt_sidebar' ); Also, try to change the name of the category/sidebar and check. Hi Abhishek, It’s still not working I tried changing the category and sidebar but nothing happens. What else could it be? Thanks again. Hello, That is odd, if possible open a ticket at the helpdesk. So I can try to take a closer look into the issue.

Comments

7 shown
Abhishek 2021-07-08T08:00:00+00:00

Hello, Please create a new sidebar using the ocean custom sidebar plugin and add the widgets as per your need. Add the below code in the functions.php file of your child theme. function prefix_cpt_sidebar( $sidebar = 'sidebar' ) { if ( is_category( 'YOUR CATEGORY NAME HERE' ) ) { $sidebar = 'your-sidebar-id'; } return $sidebar; } add_filter( 'ocean_get_sidebar', 'prefix_cpt_sidebar' ); PS- Replace the sidebar id with your own and YOUR CATEGORY NAME HERE. You can also use conditional tags according to need. https://codex.wordpress.org/Conditional_Tags

lamayas 2021-07-09T15:35:00+00:00

Hi Abhishek, The code didn’t work, the default Woocommerce sidebar is still displaying on the category. Here’s the code in case I missed something: function prefix_cpt_sidebar( $sidebar = 'sidebar' ) { if ( is_category( 'red-wine' ) ) { $sidebar = 'ocs-red-wine'; } return $sidebar; } add_filter( 'ocean_get_sidebar', 'prefix_cpt_sidebar' ); Thanks for your help.

Abhishek 2021-07-12T09:55:00+00:00

Hello, Please try to clear the cache and check. Kindly share the page URL where you are trying this and also share the snapshot of your sidebar settings/name.

lamayas 2021-07-13T17:07:00+00:00

Hi again, the site is in development so I don’t have any cache plugin installed yet. Here are the screenshots so you can have a better look: Sidebar: https://www.awesomescreenshot.com/image/10610730?key=239d35ccfb57a9579666b39e9cdff584 Widgets: https://www.awesomescreenshot.com/image/10610922?key=93007ced9373fae6be4b04e2cb94cd96 Category page: https://www.awesomescreenshot.com/image/10611227?key=261b68f325ef8851d69651f6adfef7c3

Abhishek 2021-07-14T11:37:00+00:00

Hello, Thank you for sharing teh snapshots, Kindly try the below code and check. function prefix_cpt_sidebar( $sidebar = 'sidebar' ) { if ( is_category( 'red-wine' ) ) { $sidebar = 'Red Wine'; } return $sidebar; } add_filter( 'ocean_get_sidebar', 'prefix_cpt_sidebar' ); Also, try to change the name of the category/sidebar and check.

lamayas 2021-07-14T17:13:00+00:00

Hi Abhishek, It’s still not working I tried changing the category and sidebar but nothing happens. What else could it be? Thanks again.

Abhishek 2021-07-19T11:15:00+00:00

Hello, That is odd, if possible open a ticket at the helpdesk. So I can try to take a closer look into the issue.