Here is how the loop looks? I need to exclude a few posts with the custom term, how can I manage it

    global $post, $PIXAD_Autos;
    $Settings = new PIXAD_Settings();
    $settings = $Settings->getSettings( 'WP_OPTIONS', '_pixad_autos_settings', true );

    $validate = $Settings->getSettings( 'WP_OPTIONS', '_pixad_autos_validation', true ); // Get validation settings

    $showInSidebar = pixad::getsideviewfields($validate);
    $validate = pixad::validation( $validate ); // Fix undefined index notice

    $auto_translate = unserialize( get_option( '_pixad_auto_translate' ) );


    <div class="row">
            <?php while ( have_posts() ) : the_post(); ?>
                $comment_args = array( 'status' => 'approve', 'post_id' => $post->ID, );
                $comments = get_comments($comment_args);
                $post_rating = [];
                foreach($comments as $comment){
                    $post_rating[] = floatval( get_comment_meta( $comment->comment_ID, 'rating', true ) );

            <div class="col-md-4">
                               <div class="slider-grid__inner slider-grid__inner_mod-b">

                                    <div class="card__img">
                       <?php if( has_post_thumbnail() ): ?>
                         <a href="<?php the_permalink(); ?>">
                            <?php the_post_thumbnail('autozone_latest_item', array('class' => 'img-responsive')); ?>

                    <?php else: ?>
                        <img class="no-image" src="<?php echo PIXAD_AUTO_URI .'assets/img/no_image.jpg'; ?>" alt="no-image">
                    <?php endif; ?>

                    <?php if( get_post_meta(get_the_ID(), 'pixad_auto_featured_text', true) ): ?>
                        <span class="card__wrap-label"><span class="card__label"><?php echo  get_post_meta( get_the_ID(), 'pixad_auto_featured_text', true ); ?></span></span>
                    <?php endif; ?>

                    <?php if( $validate['auto-price_show'] && $PIXAD_Autos->get_meta('_auto_price') ): ?>
                   <span class="slider-grid__price_wrap"><span class="slider-grid__price"><span><?php echo wp_kses_post($PIXAD_Autos->get_price()); ?></span></span></span> 
                    <?php endif; ?>
                    <?php do_action( 'autozone_autos_single_auto_img', $post ); ?>
                         <div class="tmpl-gray-footer">
                            <span class="tmpl-slider-grid__name"><?php echo wp_kses_post(get_the_title())?></span>
                        <?php if(!empty($post_rating)):?>
                            <div class="star-rating"><span style="width:<?php echo  esc_html( array_sum($post_rating)/count($post_rating) * 20 );?>%"></span></div>
                        <?php endif;?>      

                        <ul class="tmpl-slider-grid__info list-unstyled">

                                 <?php foreach ($showInSidebar as $id => $sideAttribute):?>
                                      <?php   $id='_'.$id; 
                                     $id = str_replace('-', '_', $id); 
                                     <?php  if( $PIXAD_Autos->get_meta($id) ): ?>
                                    <li><i class="<?php echo esc_html($sideAttribute['icon'])?>"></i>
                                        $val_attr =  $PIXAD_Autos->get_meta($id);
                                        if(!empty($auto_translate[$val_attr])  ){
                                          echo esc_html($auto_translate[$val_attr]);
                                          echo esc_html($PIXAD_Autos->get_meta($id));
                                     <?php endif; ?>

                                 <?php endforeach;?>

            <?php endwhile; ?>


2 Answers 2


are you asking how to exclude posts that contain certain text? (mod please move this to a comment, I do not have the reputation)

  • Hi, my custom post type has a taxonomy, can I exclude posts with certain taxonomy id?
    – george
    Jun 5, 2019 at 20:15
  • @george oh I'm glad you got it. Can you rate my answer useful so I can get enough reputation for comments? I am getting close to being able to comment on posts that are not mine, lol
    – brothman01
    Jun 6, 2019 at 11:32

The answer was pretty simple, sorry for bothering you)

if( has_term( 'taxonomy slug', 'taxonomy' ) ) { 

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.