0

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>'),
                $post->post_title,
                wpautop($post->post_content)
                 );
            $faq .= '</div>'; //Close the container
            }

        return $faq; //Return the HTML.
};
0

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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