简体   繁体   中英

Hi How to get child terms from a specific term and exclude some specific terms

I am struggling to add 'exclude' to exclude some terms for the below code. I cannot find the correct way to write such an array. Can anyone help me? Thanks

<?php
$terms = get_terms( 'product_cat', 'parent=175' );
$count = count($terms);
if ( $count > 0 ){
    echo '<ul>';
    foreach ( $terms as $term ) {
        echo '<li><a href="'. get_term_link( $term ) .'">'. $term->name . '</a></li>';
    }
    echo '</ul>';
}
?>

your usage of get_terms is incorrect. it takes an array of arguments like so:


$terms = get_terms( array( 
 'taxonomy' => 'product_cat',
 'parent'   =>  $parent_id,
 'exclude'  =>  array( $ids, $to, $exclude )
 ) );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM