Loop to fetch 3 post_thumbnail instances from 3 most recent custom post types named “portfolio”

Question

I am trying to display 3 post_thumbnails from a custom post type “portfolio” on my homepage template. So one from post ‘A’ , one from post ‘B’ and one from post ‘C’ The image from post A will be set as post_thumbnail(‘large’) while B & C need to be set to post_thumbnail(‘thumbnail’).

I’ve set a custom WP_Query loop and as expected it is looping through and fetching three instances of the post thumbnail for each of the most recent three “portfolio” posts. I’m just not sure how to modify the loop to only display three images not three sets of three images.

Any help much appreciated.

Here’s my code:

    <?php get_header(); ?>


    <div id="content" class="clearfix row">     
<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?>       role="article">


    <section id="work" class="row">      

        <div class="span3">
          <h3>Recent Work</h3>
          <p>Intro Lorem ipsum</p>
        </div>
          <?php $first_query = new WP_Query('post_type=portfolio');   while($first_query->have_posts()) : $first_query->the_post(); ?>
        <div class="span6">
            <a href="single-project.php">
            <?php the_post_thumbnail('medium'); ?> <!--Should be from custom post 'A' -->
            </a>
        </div>

        <div class="span3">
            <a href="single-project.php" >
             <?php the_post_thumbnail('thumbnail'); ?><!--Should be from custom post 'B' -->
            </a>

          <a href="single-project.php">
           <?php the_post_thumbnail('thumbnail'); ?><!--Should be from custom post 'C' -->
          </a>  
        </div>
0
, mattc 9 years 2012-04-10T16:13:27-05:00 0 Answers 80 views 0

Leave an answer

Browse
Browse