web hosting
build a website

Add feature image of posts to WordPress homepage

Aug 15, 2015   //   by Anthony Devine   //   Website Development tips  //  No Comments

The below code Adds thumbnails, title and text snippet onto homepage of WordPress if you use a feature image on your post, it then sets the width and height to 100 x 100. It also shows only posts from category 1 and limits the amount to 5 posts.

<div id="portfoliothumbs">
<?php query_posts('cat=1&showposts=5'); ?>
<?php if(have_posts()) : ?>
     <?php while(have_posts()) : the_post(); ?>
          <div class="post"> 
               <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
               <div class="entry">	
                    <?php the_content(); ?>

<div class="thumbnail">
    <?php the_post_thumbnail( array(100,100) ); ?>
     <?php endwhile; ?>
<?php endif; ?>