سؤال

I'm using Jigoshop and Wordpress.

My main goal is to load a different sidebar in different product categories.

I've managed to do this by using :

function jigoshop_get_sidebar() {

    if(is_shop()) get_sidebar('shop'); if ( is_product_category('poura'))
        get_sidebar('cigars');
}

in my functions.php file.

Now the issue is that I have some products that are in not just one category, so when I try doing something like this:

function jigoshop_get_sidebar() {
    if(is_shop()) get_sidebar('shop'); if ( is_product_category('poura'))
           get_sidebar('cigars'); if ( is_product_category('cigarillos'))
           get_sidebar('shop');
}

I now get both of the sidebars ('cigars','shop') because some products share both the category 'poura' and 'cigarillos'.

How is it possible to have just one sidebar under these circumstances?

Thanks again for any help!

هل كانت مفيدة؟

المحلول

An "else if" statement is not resolving your problem?

Basically what i meant was the you need a switch case not a lot of different ifs.

function jigoshop_get_sidebar() { 
    if(is_shop()) 
           get_sidebar('shop');
    elseif ( is_product_category('poura'))
           get_sidebar('cigars'); 
    elseif ( is_product_category('cigarillos'))
           get_sidebar('cigarillos');
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top