I created a custom post type called "careers" with a custom post type taxonomy called "careers_categories". Within this taxonomy I have a term called "featured". My intent is to exclude all post within the loop that contain the term "featured" with a term ID of 60, the terms will be displayed in the archive-careers.php and I am using ISOTOPE PLUGIN to create a filter for the accompanying posts.I would also like to have the "featured" post display in a hero at the top of the page. The terms are displayed as links and the filtering works with the accompanying post in the query below. The "featured" term is not displaying as a link but the post associated with the term is still displaying. It is important to note that the post that contains the term "featured" can also have the another term like "graphic_design" and I would like them to be displayed under the secondary term. please see my code below:

<?php get_header(); ?>

<div class="container">
    <div class="row">
        <div class="fl-content col-lg-12">

            <?php $terms =
            get_terms( array(
                    'taxonomy'   => 'careers_categories',
                    'hide_empty' => true,
                            'exclude'=> '60',

            <div class="hero">
                <?php if( has_term('', 'featured') ){

            <?php if( $terms ) {
            <ul id="my-category" class="filter clearfix">
                <li><a href="#" class="active" data-filter="*"><span>All</span></a></li>
                <?php foreach( $terms as $term ){
                    echo "<li><a href='#' data-filter='.$term->slug'><span>$term->name</span></a></li>";
                } ?>
            <?php }

                        if( have_posts() ) { ?>
            <div id="cpt-wrap" class="clearfix filterable-cpt  grid" data-isotope='{ "itemSelector": ".grid-item", "layoutMode": "fitRows" }'>
                <div class="cpt-content">

                    <?php while( have_posts() ): the_post(); ?>

                    <?php $terms = get_the_terms( get_the_ID(), 'careers_categories' ); ?>

                    global $post; ?>
                    <article class="grid-item cpt-item <?php if( $terms ) foreach ( $terms as $term ) { echo $term->slug.' '; }; ?>">
                        <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
                                if ( has_post_thumbnail($post->ID) ) {
                                echo the_post_thumbnail();
                                } ?>
                            <h3><?php the_title(); ?></h3>

                    <?php endwhile; ?>

            <?php } ?>

<?php get_footer();

1 Answer 1


Try below methods:

  1. Try by adding term ID in array like this 'exclude'=> '60' in array

  2. If this is not working you can try with below WP_Query loop:

 $args = array(
        'post_type' => 'careers',
        'tax_query' => array(
            'relation' => 'AND',
                'taxonomy' => 'careers_categories',
                'field'    => 'term_id',
                'terms'    => array( 60),
                'operator' => 'NOT IN',
    $query = new WP_Query( $args );
  • I have done so in the above example that is why the term is not displaying. But the posts associated with the term is displaying.
    – theartist
    Jun 5, 2020 at 16:01
  • Then may be you have selected two terms/categories in backend. Please make sure Jun 5, 2020 at 16:03
  • Yes like i stated "It is important to note that the post that contains the term "featured" can also have the another term like "graphic_design" and I would like them to be displayed under the secondary" The post only has the featured term on the backend.
    – theartist
    Jun 5, 2020 at 16:30
  • You have to write the two loop then or use WP_Query at inside that write get_term() and check Jun 6, 2020 at 2:23
  • Thanks for your help, I am a little confused to be honest. $terms = get_the_terms( get_the_ID(), 'news_categories' ); is still giving me the 'featured' posts. A little more clarification will be a big help, I appreciate it.
    – theartist
    Jun 9, 2020 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.