Support

Account

Home Forums General Issues How to filter tax terms by custom field, what am I doing wrong here? Reply To: How to filter tax terms by custom field, what am I doing wrong here?

  • I missed a closing parenthesis on my if statement

    
    <?php
    //start by fetching the terms for the product_type taxonomy
    $terms = get_terms( ‘product_type’, array(
    ‘hide_empty’ => 1
    ) );
    
    foreach( $terms as $term ) {
    
    if (in_array(‘Fiction’, get_field(‘book_group’, ‘book_type_’.$term->term_id))) {
    
    continue;
    
    echo ‘<div>’ . $term->name . ‘</div>';
    
    }
    }
    ?>