wordpress代码

wordpress archive.php或category.php代码

 <?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 = ''; 
                                $image = '';
                               if ( has_post_thumbnail() ) {
            
                                  $image = get_the_post_thumbnail( $post->ID, 'medium', array(
                                     // 'title' => $title_attribute,
                                     // 'alt'   => $img_alt,
                                       'alt'   => $title,
                                       'class' => 'rounded-top',
                                       'style' => 'width:100%;'
                                    ) ) ;
                              }
            ?>
             <article class="single-blog">
                        <a href="<?php the_permalink(); ?>" class="single-blog-img">
                          <?php echo $image;?>
                           <div class="overlay flex">
                              <i class="fa-solid fa-arrow-up-right-from-square"></i>
                           </div>
                        </a>
                        <!--/.single-blog-img-->
                        <div class="single-blog-content">
                           <a class="titlelink" href="<?php the_permalink(); ?>">
                              <h3><?php echo $title?></h3>
                           </a>
                           <div class="wrapper-date-author flex">
                              <i class="fa-regular fa-clock"></i> <?php echo $dateday?> 
                              
                           </div>
                           <!--/.wrapper-date-author-->
                           <div class="excerpt">
                              <p><?php echo $postexcerpt?></p>
                           </div>
                           <!--/.excerpt-->
                        </div>
                        <!--/.single-blog-content-->
                     </article>
                        <?php endwhile; ?> 
                <?php endif; ?>