Title: Getting posts without thumbnail
Last modified: August 20, 2016

---

# Getting posts without thumbnail

 *  [jlindblom](https://wordpress.org/support/users/jlindblom/)
 * (@jlindblom)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/getting-posts-without-thumbnail/)
 * Hello! Hope you’re fine! Have a little WordPress-wondering, which I would some
   help with! I just wonder how to get the post which not have a thumbnail connected
   to the post. When there is a post wihtout thumbnail, I want to show the title
   and text for the post instead of the picture. Someone who know how to do this?
 * Thanks for all help, and if I forgot to tell you some information, please tell
   me, and I will give you the missing information. (And please sorry for my bad
   english!)
 * The code, which getting the “thumbnail”:
 *     ```
       <?php
       $postPosts = new WP_Query();
       $postPosts->query('');
       ?>
   
       <?php
       while ($postPosts->have_posts()) : $postPosts->the_post(); ?>
       <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
       <div class="thumbnail">
       <?php
       if ( has_post_thumbnail() ) {
       the_post_thumbnail();
       }
       ?>
       </div>
       </div>
       <?php endwhile; ?>
       ```
   
 * Take care!
 * Sincerly!

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/getting-posts-without-thumbnail/#post-2678333)
 *     ```
       if ( has_post_thumbnail() ) : the_post_thumbnail();
       else: ?><h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
       <?php endif;?>
       ```
   
 *  Thread Starter [jlindblom](https://wordpress.org/support/users/jlindblom/)
 * (@jlindblom)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/getting-posts-without-thumbnail/#post-2678407)
 * Thanks for your fast reply Esmi! I used your code, and as many other times I 
   got this error:
 * **Parse error: syntax error, unexpected T_ENDWHILE on line 80 **
 * What am I doing wrong? Really thankful for your helping esmi! Thanks again!
 * See the code I used;
 *     ```
       <?php
       $postPosts = new WP_Query();
       $postPosts->query('');
       ?>
   
       <?php
       while ($postPosts->have_posts()) : $postPosts->the_post(); ?>
       <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
       <div class="thumbnail">
       <?php
       if ( has_post_thumbnail() ) : the_post_thumbnail();
       else: ?><h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
       }
       ?>
       </div>
       </div>
       <?php endwhile; ?>
   
       <?php endif;?>
       ```
   
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/getting-posts-without-thumbnail/#post-2678510)
 * There aren’t 80 lines of code in that cide block. If you need to post the whole
   file, drop a copy into the [WordPress pastebin](http://wordpress.pastebin.com/)
   and post the pastebin url here.
 *  Thread Starter [jlindblom](https://wordpress.org/support/users/jlindblom/)
 * (@jlindblom)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/getting-posts-without-thumbnail/#post-2678520)
 * Hello esmi! Thanks for your reply! I uploaded the whole code here: [http://pastebin.com/RFnmdTM9](http://pastebin.com/RFnmdTM9).
 * I changed it a little bit now, and now I’m getting the information (as title 
   and text) even if there is no thumbnail/featured image attached to the post. 
   See here, [blog.jimmylindblom.se](http://blog.jimmylindblom.se). Sorry now, but
   I want one more solution. And I hope you can help me. You seem to be to WordPress,
   what “Foppa” was to the icehockey!:)
 * As you can see at [blog.jimmylindblom.se](http://blog.jimmylindblom.se), there
   is a title and text even for the posts which include a thumbnail, like on post**
   TEST 8** (the text which has a line through the text). I only want to show content
   text when there is no thumbnail. I’m going to make in this way. I will have some
   different categories, like **photos**, **tweets**, **portfolio** and **blog**.
   And for every category, I want different styles of showing posts. Like for category**
   photos** I only want the thumbnail to show and title, for **blog** I want to 
   show title and content, etc.
 * Is there a difficult solution behind this? I now how to style each post different
   by using CSS, but PHP isn’t my best side, sorry. And I need the PHP to make to
   show and hide title etc, I guess. Hope I’ve got all the information within this
   post to explain my problem for you. And I want you to know I’m really glad for
   your help, and thankful! Have a nice day/night!
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/getting-posts-without-thumbnail/#post-2678523)
 * Try changing:
 *     ```
       <?php if ( has_post_thumbnail() ) {
       the_post_thumbnail();} ?>
       <?php the_content('Read the rest of this entry &raquo;'); ?>
       ```
   
 * to:
 *     ```
       <?php if ( has_post_thumbnail() ) the_post_thumbnail();}
       else the_content('Read the rest of this entry &raquo;'); ?>
       ```
   
 *  Thread Starter [jlindblom](https://wordpress.org/support/users/jlindblom/)
 * (@jlindblom)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/getting-posts-without-thumbnail/#post-2678525)
 * Thanks for your kind help esmi! That worked fine!:) What to do now, as I’m new
   here, will I change this thread to “solved”? Because if I got more questions 
   about this, how to do then, start a new thread?
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/getting-posts-without-thumbnail/#post-2678527)
 * Start a new thread as we’ve dealt with your current issues.
 *  Thread Starter [jlindblom](https://wordpress.org/support/users/jlindblom/)
 * (@jlindblom)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/getting-posts-without-thumbnail/#post-2678554)
 * Thanks esmi! I will do! But first I wonder one more thing. If I want different
   output for the different categories, how to do then?
 * I mean, if i want to show tags, content and title for the category **blog**, 
   and only title and content for the category **tweets**, and for the category **
   photos **just thumbnail and title. How to do then? I know the codes for tags 
   etc, but not how to make the if, else etc.
 * Thanks again for your kind helping!

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

The topic ‘Getting posts without thumbnail’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 8 replies
 * 2 participants
 * Last reply from: [jlindblom](https://wordpress.org/support/users/jlindblom/)
 * Last activity: [13 years, 12 months ago](https://wordpress.org/support/topic/getting-posts-without-thumbnail/#post-2678554)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
