WordPress.org

Ready to get started?Download WordPress

Forums

Display post from category with thumbnail and title, (3 posts)

  1. pri2sh
    Member
    Posted 2 years ago #

    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

  2. KrashKartMedia
    Member
    Posted 2 years ago #

    you need to find the code that does this, and then create a function, then reference it in the file to get the function.

    also read this:

    http://wordpress.org/support/topic/show-title-and-thumbnails-only-for-category-page?replies=8

  3. pri2sh
    Member
    Posted 2 years ago #

    i tried the code posted there and got blank page instead. i tried reference but no luck

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.