Title: adding post image
Last modified: August 20, 2016

---

# adding post image

 *  [daverogers](https://wordpress.org/support/users/daverogers/)
 * (@daverogers)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/adding-post-image/)
 * I have the code below to list the lastest posts on a page outside the content
   area. I am trying to add the post image to each one aswell but cant seem to get
   this correct. I just want a small image on each post line.
 *     ```
       <?php
           $args = array( 'numberposts' => 6, 'post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date");
           $postslist = get_posts( $args );
           foreach ($postslist as $post) : setup_postdata($post); ?>
              <div class="events">
                    <p><strong><?php the_date(); ?></strong></p>
                  <p><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" target="blank" ><?php the_title(); ?></a></p>
             </div><br>
       <?php endforeach; ?>
       ```
   
 * Many thanks

Viewing 8 replies - 1 through 8 (of 8 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/adding-post-image/#post-3232992)
 * what is a ‘post image’ ?
 * = any one of the images in the post?
 * for instance, try the plugin [http://wordpress.org/extend/plugins/get-the-image/](http://wordpress.org/extend/plugins/get-the-image/)
 * or
    = ‘featured image’?
 * [http://codex.wordpress.org/Function_Reference/the_post_thumbnail](http://codex.wordpress.org/Function_Reference/the_post_thumbnail)
 *  Thread Starter [daverogers](https://wordpress.org/support/users/daverogers/)
 * (@daverogers)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/adding-post-image/#post-3232998)
 * featured image sorry.
 *  Thread Starter [daverogers](https://wordpress.org/support/users/daverogers/)
 * (@daverogers)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/adding-post-image/#post-3232999)
 * I have read this already [http://codex.wordpress.org/Function_Reference/the_post_thumbnail](http://codex.wordpress.org/Function_Reference/the_post_thumbnail)
   
   unfortunately IM no too good with coding.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/adding-post-image/#post-3233066)
 * I guess not 🙂 Pretty much cut and paste.
 *     ```
       <p><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" target="blank" >
       <?php
       if ( has_post_thumbnail() ) {
         the_post_thumbnail();
       }
       ?>
       <?php the_title(); ?></a></p>
       ```
   
 *  Thread Starter [daverogers](https://wordpress.org/support/users/daverogers/)
 * (@daverogers)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/adding-post-image/#post-3233069)
 * Thanks BC tried that before I pored this it didnt work.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/adding-post-image/#post-3233075)
 * I pasted your code with my modification into a blank test page and it works fine.
   Note that the image must be attached as a featured image. Simply inserting a 
   thumbnail will not work. The function name is misleading.
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/adding-post-image/#post-3233078)
 * try alternatively, to change this line:
 *     ```
       <p><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" target="blank" ><?php the_title(); ?></a></p>
       ```
   
 * for instance to:
 *     ```
       <p><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" target="blank" ><?php echo get_the_post_thumbnail($post->ID); ?><?php the_title(); ?></a></p>
       ```
   
 * what exactly is ‘not working’?
    can you provide a link to your site to illustrate
   the result of the suggested codes?
 *  Thread Starter [daverogers](https://wordpress.org/support/users/daverogers/)
 * (@daverogers)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/adding-post-image/#post-3233095)
 * Hi the page is ehre
 * [http://www.bradleystokeradio.org.uk/index.php/player](http://www.bradleystokeradio.org.uk/index.php/player)

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘adding post image’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 8 replies
 * 3 participants
 * Last reply from: [daverogers](https://wordpress.org/support/users/daverogers/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/adding-post-image/#post-3233095)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
