WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the following as part of a shortcode I'm creating:

$loop = new WP_Query(array('post_type' => 'client', 'posts_per_page' => $limit, 'orderby' => $orderby)); 

        $preoutput = '<div class="outer">';
        $postoutput = '</div>';
        while ($loop->have_posts()){
            $output .= '<div class="box box-'.$columns.'"><h2>hello</h2>'.the_post_thumbnail(); 
            $output .= '<div class="text"><h2 class="entry-title"><a href="'.get_permalink().'">'.get_the_title().'</a></h2>'.get_the_excerpt().'</div></div>';  
            $finaloutput = $preoutput . $output . $postoutput;

However, the post thumbnail doesn't appear in the markup, it appears just at the top of the post - why would it do this?

share|improve this question
up vote 1 down vote accepted

You are using the_post_thumbnail, which directly outputs the thumbnail in an image tag. You need to use get_the_post_thumbnail instead, which returns the image.

share|improve this answer
Perfect! Thank you! – user319940 Mar 18 '13 at 17:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.