Title: Posts with images
Last modified: August 22, 2016

---

# Posts with images

 *  Resolved [Roland Yegorov](https://wordpress.org/support/users/rolandjeg/)
 * (@rolandjeg)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/posts-with-images-1/)
 * Hello, how can I display recent posts with a featured image?

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

 *  [stephencottontail](https://wordpress.org/support/users/stephencottontail/)
 * (@stephencottontail)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/posts-with-images-1/#post-5572758)
 * What theme are you using? Where did you download it from?
 *  Thread Starter [Roland Yegorov](https://wordpress.org/support/users/rolandjeg/)
 * (@rolandjeg)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/posts-with-images-1/#post-5572808)
 * I made a custom theme. Using 4.0.1 WordPress
 *  [stephencottontail](https://wordpress.org/support/users/stephencottontail/)
 * (@stephencottontail)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/posts-with-images-1/#post-5572810)
 * In general, you’d do something like this:
 *     ```
       <?php
       if ( has_post_thumbnail() ) :
         the_post_thumbnail();
       endif;
       ?>
       ```
   
 * You can use CSS to style the image as necessary.
 *  Thread Starter [Roland Yegorov](https://wordpress.org/support/users/rolandjeg/)
 * (@rolandjeg)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/posts-with-images-1/#post-5572812)
 * Thanks, I’ll try it and respond in an hour.
    How can I target images to be those
   thumbnails?
 *  [stephencottontail](https://wordpress.org/support/users/stephencottontail/)
 * (@stephencottontail)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/posts-with-images-1/#post-5572814)
 * First make sure you’ve added support for post thumbnails in your theme’s `functions.
   php`:
 * `add_theme_support( 'post-thumbnails' );`
 * Then, you should be able to assign a post thumbnail to a blog post or static 
   page in the editing screen. There should be a metabox in the right-hand column
   labeled “Featured Image” and a link to “Set featured image”. Clicking that link
   allows you to choose an image from your Media Library or to upload one. Check
   out Post Thumbnails in the Codex for more information: [http://codex.wordpress.org/Post_Thumbnails](http://codex.wordpress.org/Post_Thumbnails)
 *  Thread Starter [Roland Yegorov](https://wordpress.org/support/users/rolandjeg/)
 * (@rolandjeg)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/posts-with-images-1/#post-5572816)
 * Thank you both for contributing. I’ll make sure to try when I’m at my computer.
   After 2-3h.
 *  Thread Starter [Roland Yegorov](https://wordpress.org/support/users/rolandjeg/)
 * (@rolandjeg)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/posts-with-images-1/#post-5572839)
 * My functions.php does not recognize the code:
 * if ( function_exists( ‘add_theme_support’ ) ) {
    add_theme_support( ‘post-thumbnails’);
   set_post_thumbnail_size( 150, 150, true ); // default Post Thumbnail dimensions(
   cropped)
 * // additional image sizes
    // delete the next line if you do not need additional
   image sizes add_image_size( ‘category-thumb’, 300, 9999 ); //300 pixels wide (
   and unlimited height) }
 * or simply
 * add_theme_support( ‘post-thumbnails’ );
 * The code just appears as text in the admin panel. :/
 *  [stephencottontail](https://wordpress.org/support/users/stephencottontail/)
 * (@stephencottontail)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/posts-with-images-1/#post-5572864)
 * Is that your entire `functions.php`? Do you have the opening `<?php` tag in the
   file? Is the file named `functions.php` (note the plural)?
 *  Thread Starter [Roland Yegorov](https://wordpress.org/support/users/rolandjeg/)
 * (@rolandjeg)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/posts-with-images-1/#post-5572867)
 * OK, one problem solved. The featured image metabox appeared in the admin panel.
   But can the featured image be displayed on the recent posts tab?
 * Here is my index.php if I did not make a lot of sense. I reckon there should 
   be an additional php snippet to display the featured image?
 * [http://pastebin.com/fqgPMMxZ](http://pastebin.com/fqgPMMxZ)
 *  [stephencottontail](https://wordpress.org/support/users/stephencottontail/)
 * (@stephencottontail)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/posts-with-images-1/#post-5572868)
 * To clarify, when you say the “recent posts tab”, are you referring to WordPress’
   built-in widget, or are you referring to a section in the `index.php` that you
   posted a link to?
 *  Thread Starter [Roland Yegorov](https://wordpress.org/support/users/rolandjeg/)
 * (@rolandjeg)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/posts-with-images-1/#post-5572870)
 * I’m referring to this part of the code: [http://pastebin.com/F1wN5k7x](http://pastebin.com/F1wN5k7x)
 * Which displays recent posts.
 *  [stephencottontail](https://wordpress.org/support/users/stephencottontail/)
 * (@stephencottontail)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/posts-with-images-1/#post-5572872)
 * In general, you would do something like this:
 *     ```
       <div class="col-md-10">
         <?php while(have_posts()) : the_post(); ?>
         <?php if ( has_post_thumbnail() ) : ?>
         <?php the_post_thumbnail(); ?>
         <?php endif; ?>
         <h3><a href="<?php the_permalink('http://viso.lv/wordpress/?p=76'); ?>"><?php the_title(); ?></a></h3>
         <p><?php the_excerpt(); ?></p>
         <p class="text-muted">Опубликовано <?php the_author(); ?> на <?php the_time('F jS, Y'); ?></p>
         <?php endwhile; wp_reset_query(); ?>
       </div>
       ```
   
 * You can then use CSS to style the image as needed.
 *  Thread Starter [Roland Yegorov](https://wordpress.org/support/users/rolandjeg/)
 * (@rolandjeg)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/posts-with-images-1/#post-5572874)
 * Woohoo thanks a lot! Now it’s time to proceed. 🙂
 * Can I ask one more question?
    How would you suggest to code my navbar if it’s
   hardcoded with simple **a** tags? Should I implement php snippets or just put
   a link to the pages?
 * Here is the code for the menu: [http://pastebin.com/GMZ1uFsh](http://pastebin.com/GMZ1uFsh)
 *  [stephencottontail](https://wordpress.org/support/users/stephencottontail/)
 * (@stephencottontail)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/posts-with-images-1/#post-5572875)
 * You could call [wp_nav_menu()](http://codex.wordpress.org/Function_Reference/wp_nav_menu)
   to display the menu instead. An advantage of doing it this way is that `wp_nav_menu()`
   automatically adds a bunch of HTML classes that can be used for styling via CSS.
   You would have to call [register_nav_menus()](http://codex.wordpress.org/Function_Reference/register_nav_menus)
   in your `functions.php` for it to work:
 * `register_nav_menus( array( 'primary' => 'Primary Menu' ) );`
 * And then call it in your `header.php` like this:
 * `<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>`
 *  Thread Starter [Roland Yegorov](https://wordpress.org/support/users/rolandjeg/)
 * (@rolandjeg)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/posts-with-images-1/#post-5572910)
 * Thank you a lot once again! Now I feel more confident in WordPress and the website
   is building well. Have a nice day/evening! 🙂

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

The topic ‘Posts with images’ is closed to new replies.

## Tags

 * [image](https://wordpress.org/support/topic-tag/image/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)

 * 15 replies
 * 2 participants
 * Last reply from: [Roland Yegorov](https://wordpress.org/support/users/rolandjeg/)
 * Last activity: [11 years, 8 months ago](https://wordpress.org/support/topic/posts-with-images-1/#post-5572910)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
