Support

Account

Home Forums General Issues If checkbox has specific value for Elseif condition

Helping

If checkbox has specific value for Elseif condition

  • I have a archive page, where it has if, elseif and else statemenet and i’m trying to make elseif work with checkboxes which can have two values, product and hidden. But elseif needs to check only one value, product. in_array() gives me an error if there is only one value. How can I make my code work if checkbox has only one value selected?

    Here’s my code:

    
    $term = get_queried_object();
    
    if( $term_has_children ) :
    
    // do if
    
    elseif( in_array('product', get_field('is_category', $term->taxonomy . '_' . $term->term_id)) ) :
    
    // do elseif 
    
    else :
    
    // do else
    
    endif;
    
  • Is the field is_category a checkbox or a true/false field?

    Can you provide a screenshot of your field setup so that I can see what you’re working with.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.