The only show featured post by category

// the query
$the_query = new WP_Query( array( 
  'post_type' => 'post',
  'posts_per_page' => 1,
  'offset' => 0,
  'cat' => 3, // Category ID
  'order'   => 'DESC',
  'orderby' => 'date'
  
  ) ); ?>

<?php if ( $the_query->have_posts() ) : ?>
<!-- the loop -->
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); 
    $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large' );?>

<header class="hc-showcase" style="background: url('<?php echo $thumb['0'];?>') no-repeat center center/cover;">
  <a href="<?php the_permalink(); ?>">
    <h2><?php the_title(); ?></h2>
  </a>
  <p><?php the_excerpt(); ?></p>
  <?php the_date( 'F j, Y', '<span>', '</span>' ); ?>
  <a href="<?php the_permalink(); ?>" class="hc-btn">Continue reading <i class="fas fa-chevron-right"></i></a></p>
  <?php endwhile; ?>
  <!-- end of the loop -->

  <!-- pagination here -->

  <?php wp_reset_postdata(); ?>

  <?php else : ?>
  <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
  <?php endif; ?>

</header>

Leave a Reply

Your email address will not be published. Required fields are marked *