Sidebars Not Showing On Woocommerce Category Pages

Author
Topic
#3505

Hi Smart Plugins Staff,

I’m trying to get different sidebars to show on different woocommerce categories. The functionality is supposed to work, but it’s not working for category pages. I saw that I can select “Product Categories” on your list, but then it doesn’t show me which ones, I can only select all of them.

I tried using the category page IDS, and those aren’t working. How can I get these sidebars to show on specific category pages?

Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
Author
Replies
  • #3506

    Developers Guide PDF that comes with the plugin contains PHP code example how to control each sidebar visibility, and you can use any conditional to determine if the sidebar should be displayed or not done using [b]Sidebar Activation Filter[/b].

  • #3507

    Thanks,

    I added the following code to my functions.php file in my x-child theme:

    add_filter(‘sss_sidebar_activation_1’, ‘sidebar_1_activation’);
    function ‘sidebar_1_activation'($active) {
    if (!$active) {
    $active = is_category(‘Products’);
    }
    return $active;
    }

    It then crashes my site. The sidebar id is 1, and the category is products. I currently have the sidebar set for custom rules, but I don’t have any enabled. What do I need to change?

    Thanks!

  • #3510

    Why would you add quotes in function name? That’s why it crashes. Here is the fixed example:

    [scode lang=”php”]add_filter(‘sss_sidebar_activation_1’, ‘sidebar_1_activation’);
    function sidebar_1_activation($active) {
    $active = is_category(‘products’);
    return $active;
    }[/scode]

    This code will show the sidebar only for Products category. But, WooCommerce uses own taxonomy Category with the name ‘product_cat’, so your code will not affect WooCommerce pages. Here is the changed code:

    [scode lang=”php”]add_filter(‘sss_sidebar_activation_1’, ‘sidebar_1_activation’);
    function sidebar_1_activation($active) {
    $active = is_tax(‘product_cat’, ‘name of the product category’);
    return $active;
    }[/scode]

    Replace [b]name of the product category[/b] with the name of the product category.

    Regards,
    Milan

  • #3512

    HI Milan,

    That was exactly what I needed, thank you!

    I copy pasted that script from the developers guide, it has quotes in it. The only thing I changed was ‘Products’

    Its the first one under: sss_sidebar_activation_$id

    Ari

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Sidebars Not Showing On Woocommerce Category Pages’ is closed to new replies.