获取封面图 Feature Image

<img src="
  <?php 
      if (has_post_thumbnail($post->ID)) : 
          $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail'); 
          echo esc_url($image[0]); 
      else:
          echo get_template_directory_uri() .'/images/1.jpg';
      endif; 
  ?>" alt="<?php the_title(); ?>" class="rounded">

 


版本号 #1
由 Wayne 创建于 14 十一月 2024 03:23:48
由 Wayne 更新于 14 十一月 2024 03:24:37