wordpress代码

首页,产品分类列表和各分类的产品的代码

    <!-- Start Bestsellers Area -->
        <section class="bestsellers-area pt-100 pb-70">
            <div class="container">
                <div class="section-title">
                    <h2>All Products</h2>
                </div>

                <div class="tab bestsellers-list-tab">
                    <ul class="tabs">
                         <?php 
    $menuarr = wp_get_nested_menu_array(INFLAMENU2);//INFLAMENU2 in functions.php
    foreach ($menuarr as $key => $v) {
       // pre($v);
             $url = $v['url'];
              $object_id = $v['object_id'];
              $name = $v['title'];
        echo '<li><a href="">'.$name.'</a></li>';
    }
        
        ?>
                    
                    </ul>

                    <div class="tab_content">
                        
                     <?php 
                         foreach ($menuarr as $key => $v) {
       // pre($v);
             $url = $v['url'];
              $object_id = $v['object_id'];
              $name = $v['title'];
        
     
    ?>  

                        <div class="tabs_item">
                            <div class="row">

         <?php 
    $args         = array(
      'post_type' => 'products',
            'posts_per_page'      => 8,
            // 'cat'                 => $object_id,
             'tax_query' => array(
                          array(
                            'taxonomy' => 'catepro',
                            'field' => 'id',
                            'terms' => array($object_id ),
                            'include_children' => false,
                            'operator' => 'NOT IN'
                          )
                        ),
            'orderby'             => 'date',
            'ignore_sticky_posts' => true,
           //  'post__not_in'        => array( $post->ID ),
        );
     

        $loop = new WP_Query( $args );
        

 while ( $loop->have_posts() ) :
     $loop->the_post();
 
  $title = $post->post_title;
  $excerpt = $post->post_excerpt;

  $image = '';
   
   if ( has_post_thumbnail() ) {
   
     $image = get_the_post_thumbnail( $post->ID, 'medium', array(
       //  'title' => $title_attribute,
         'alt'   => $title,
       ) ) ;
     }
 
        ?>
                                <div class="col-lg-3 col-sm-6">
                                    <div class="single-bestsellers-products">
                                        <div class="bestsellers-products-image">
                                            <a href="<?php the_permalink(); ?>"><?php echo $image;?></a>
                                        </div>
            
                                        <div class="bestsellers-products-content">
                                            <h3>
                                                 <a href="<?php the_permalink(); ?>"><?php echo $title;?></a>
                                            </h3>
                                            <ul class="rating">
                                                <li><i class='bx bxs-star'></i></li>
                                                <li><i class='bx bxs-star'></i></li>
                                                <li><i class='bx bxs-star'></i></li>
                                                <li><i class='bx bxs-star'></i></li>
                                                <li><i class='bx bxs-star'></i></li>
                                            </ul>
                                            <span><?php echo $excerpt;?></span>
                                        </div>
                                    </div>
                                </div>
                      <?php endwhile; ?>  

                            </div>
                        </div>
                        
                        <?php
                        }
                        ?>
                    </div>
                </div>
            </div>
        </section>
        <!-- End Bestsellers Area -->