Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Exclude custom taxonomy term

Hi! Why I cannot exclude the custom taxonomy term "series" in my home loop? I tried everthing. =( My code:

    <?php

$my_categories = get_terms( array(

'taxonomy' => 'canais',

'parent' => 0,

'orderby' => 'date',

'order'=> DESC,

'field' => 'slug',

 'term'     => 'series',

  'operator'  => 'NOT IN',

) );

$my_categories_count = count( $my_categories );

if ( $my_categories_count > 0 && is_array( $my_categories ) ) {

foreach ( $my_categories as $single_cat ) { ?>

    <a  href="<?php echo get_term_link($single_cat) ?>"><h2><?php echo $single_cat->name; ?></h2></a>

    <?php
        $cat_posts_args = array(
            'showposts' => '3',
            'orderby' => 'date',
            'order'=> DESC,
            'post_status' => 'publish',
            'tax_query' => array(
                array(
                    'taxonomy' => 'canais',
                    'field' => 'id',
                    'terms' => $single_cat->term_id,
                    'include_children' => true,

                )
            )
        );
        $cat_posts = new WP_Query( $cat_posts_args );
        if ( $cat_posts->have_posts() ) :
                    echo '<div class="card-deck-wrapper">';
        echo '<div class="card-deck">';
            while ( $cat_posts->have_posts() ) : $cat_posts->the_post(); ?>



            <?php endwhile;


        endif;

        wp_reset_postdata();

    } // end foreach

}

?>