wordpress代码

产品分类列表页面的代码,先overwrite template -- taxonomy-catepro.php


        <!-- Start Shop Area -->
        <section class="shop-area pt-50 pb-50">
            <div class="container">
                <div class="row">
                    <div class="col-lg-8 col-md-12">
                       
                        <div id="products-collections-filter" class="row">


 
                     <?php if( have_posts() ): ?>               
                        <?php while( have_posts() ): the_post(); ?>
                            <?php 
                             $title = $post->post_title;
                              $dateday = substr($post->post_date,0,10);
                               $postexcerpt = $post->post_excerpt;
                              // echo $postexcerpt;
                               $postcnt = $post->post_content;
                               if($postexcerpt==''){
                                    $postcnt = strip_tags($postcnt);
                                    $num = 60;
                                    $postexcerpt = mb_substr($postcnt,0,$num,'UTF-8').'...';
                                 
                               }  

                             // $image = get_the_post_thumbnail_url( get_the_ID(), 'medium' );

                               $image = '';
                               if ( has_post_thumbnail() ) {
            
                                  $image = get_the_post_thumbnail( $post->ID, 'medium', array(
                                     // 'title' => $title_attribute,
                                     // 'alt'   => $img_alt,
                                       'alt'   => $title,
                                       'class' => 'card-img-top'
                                    ) ) ;
                              }

            ?>


                            <div class="col-lg-4 col-sm-6">
                                <div class="single-shop-products">
                                    <div class="shop-products-image">
                                         <a   href="<?php the_permalink(); ?>"><?php echo $image;?></a>
                                    </div>
        
                                    <div class="shop-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 $postexcerpt?></span>
                                    </div>
                                </div>
                            </div>
                          
                  <?php endwhile; ?> 
                <?php endif; ?>  
        
        
                            <?php 
                                    require_once get_template_directory ().'/tpl/pagelist.php'; 
                                ?>

                            

                        </div>
                    </div>