0

if($atts['member_sort']==='yes'){
    $acategories = get_terms( $atts['tax_name']);
  //print_r($categories);
   if (!empty($acategories)):
       foreach ($acategories as $category):
     $argscp = [
      'post_type' => $atts['post_type'],
      'posts_per_page' => -1,
      'order' => 'ASC',
      'orderby' => 'title',
      'tax_query' => array(
       array(
        'taxonomy' => $atts['tax_name'],
        'field'    => 'term_id',
        'terms'    => $category->term_id,
       ),
      ),
     ];
     $querycp = new WP_Query($argscp);
     while ($querycp->have_posts()) : $querycp->the_post();
      @$featured_img_url = get_the_post_thumbnail_url($post->ID,'full');
        @$featured_mimg_url = get_the_post_thumbnail_url($post->ID,'medium_large');
        @$categories = get_the_terms( $post->ID, $atts['tax_name']);
        $terms_string = join(' / ', wp_list_pluck($categories, 'name'));
      $check_mc = $categories;
      if($check_mc[0]->term_taxonomy_id==$category->term_id){
      ?>
     <div class="et_pb_column et_pb_column_1_<?php echo $atts['per_col'];?> portfolio-item <?php echo $category->slug; /*if (is_array($categories) || is_object($categories)){ foreach( $categories as $category ){echo $category->slug.' ' ;}}*/?>">
             <a href="<?php echo the_permalink();?>" class="link-text">
               <div class="portfolio-wrap" style="background-image: url(<?php echo $featured_mimg_url;?>);">
                 <div class="portfolio-info">
                     <h4><?php the_title();?></h4>
                     <span class="project_cat"><?php echo $terms_string;?></span>
                     <a href="<?php echo the_permalink();?>">
                      <div class="port_link"><span class='et-pb-icon'></span></div>
                  </a>
                 </div>
               </div>
           </a>
            </div>
   <?php }
     endwhile;
     wp_reset_postdata(); 
    endforeach;
   endif;
   $argsncp = [
      'post_type' => $atts['post_type'],
      'posts_per_page' => -1,
      'order' => 'ASC',
      'orderby' => 'title',
      'taxonomy' => $atts['tax_name'],
      //'field' => 'term_id',
      //'operator' => 'NOT IN',
      'tax_query' => array(
       array(
        'taxonomy' => $atts['tax_name'],
        //'field'    => 'term_id',
        //'terms'    => $category->term_id,
        'operator' => 'NOT EXISTS',
       ),
      ),
     ];
    $queryncp = new WP_Query($argsncp);
    while ($queryncp->have_posts()) : $queryncp->the_post();
       @$featured_img_url = get_the_post_thumbnail_url($post->ID,'full');
       @$featured_mimg_url = get_the_post_thumbnail_url($post->ID,'medium_large');
       @$categories = get_the_terms( $post->ID, $atts['tax_name']);
       $terms_string = join(' / ', wp_list_pluck($categories, 'name'));
     ?>
     <div class="et_pb_column et_pb_column_1_<?php echo $atts['per_col'];?> uap portfolio-item <?php if (is_array($categories) || is_object($categories)){ foreach( $categories as $category ){echo $category->slug.' ' ;}}?>">
             <a href="<?php echo the_permalink();?>" class="link-text">
               <div class="portfolio-wrap" style="background-image: url(<?php echo $featured_mimg_url;?>);">
                 <div class="portfolio-info">
                     <h4><?php the_title();?></h4>
                     <span class="project_cat"><?php echo $terms_string;?></span>
                     <a href="<?php echo the_permalink();?>">
                      <div class="port_link"><span class='et-pb-icon'></span></div>
                  </a>
                 </div>
               </div>
           </a>
            </div>
   <?php
    endwhile;
    wp_reset_postdata(); 
   }

Jagdish Sarma Asked question January 21, 2022
Add a Comment