• I want to display post from a specific category with title and thumbnail. the php code i’m using displays only thumbnail but not title from category and i’m having problem with displaying title the code i use is

    <?php
    
    $header_thumbs = get_posts(' $args&category_name=events&posts_per_page=4');
    if( $header_thumbs ) :
      foreach( $header_thumbs as $header_thumb ) {
      setup_postdata($header_thumb);
    
      echo '<a href="' . get_permalink($header_thumb->ID) . '">' . get_the_post_thumbnail($header_thumb->ID) .   '</a>';
      }
    endif;
    ?>

    I tried get_title code but it displayed title of home page.
    please help me complete this code

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display post from category with thumbnail and title,’ is closed to new replies.