I am trying to display a thumbnail in a foreach loop. The thumbnail is a new image size I have added called "plant-thumb". I have all the desired elements displaying properly except for the thumbnail. Here is my code:

      foreach ( $posts as $post ) {   

       echo '<a class="modalLink" href="plant-list-accordion'.$post->ID.'" >';
       echo get_the_post_thumbnail($thumbnail->ID, 'plant-thumb'); //Here is where I'm trying to output the bespoke thumbnail
       echo '</a>';

            $faq .= sprintf(('<div class="modal mfp-hide" id="plant-list-accordion'.$post->ID.'">%1$s<div>%2$s</div>'),
            $faq .= '</div>'; //Close the container

        return $faq; //Return the HTML.

1 Answer 1


echo get_the_post_thumbnail($post->ID, 'plant-thumb');

  • 1
    Please add an explanation to your answer: why could that solve the problem?
    – fuxia
    Commented Jul 25, 2013 at 11:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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