Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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)); 

    if($loop){
        $preoutput = '<div class="outer">';
        $postoutput = '</div>';
        while ($loop->have_posts()){
            $loop->the_post();  
            $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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.