Excluded Custom Taxonomy Term Posts Displaying in loop


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();
, , , theartist 3 years 2020-06-04T15:11:43-05:00 0 Answers 108 views 0

Leave an answer