wordpress代码

wordpress搜索页面search代码


<?php
  $dmsearchkey = get_search_query();
   if($dmsearchkey ==''){
       
        echo '<div style="width:100%;padding:100px;text-align:center;font-size:30px">Please input search keywords</div>';
       
   }else{
   ?>
           <section>
            <div class="container">
                <div class="row mt-n2-9">
                    <div class="col-lg-12">
                        <div class="row g-xl-5 mt-n2-2">
                               <?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%;'
                                    ) ) ;
                              }
            ?>
                             
                            <div class="col-md-3 mt-2-2 wow fadeInUp" data-wow-delay="200ms">
                                <article class="card card-style02 rounded h-100">
                                  <a   href="<?php the_permalink(); ?>">  <div class="blog-img position-relative overflow-hidden image-hover">
                                        <?php echo $image;?>
                                    </div></a>
                                    <div class="card-body p-1-6 p-lg-2-3">
                                        <h4 class="mb-3"><a href="<?php the_permalink(); ?>"><?php echo $title?> </a></h4>
                                         <span class="blog-date"><?php echo $dateday?> </span>
                                        <p class="mb-3"><?php echo $postexcerpt?> </p>
                                         
                                    </div>
                                </article>
                            </div>
                  <?php endwhile; ?> 
                <?php endif; ?>  
                       
                          <?php 
                                    require_once TPLCURROOT.'/tpl/pagelist.php'; 
                                ?>           
                        </div>
                    </div>
                   
                </div>
            </div>
        </section>


<?php 

}

?>

 

===================