Hi can someone explain me why the thumbnail is showing outside from the div? am i using the function correctly to concatenate the thumbnail inside the $list. BTW im running this code inside a shortcode that's why i use a concatenate function.
$list = "";
$list = " <div class='box'> ". the_post_thumbnail('post-thumbnail') . "</div>";
Hi can someone explain me why the thumbnail is showing outside from the div? am i using the function correctly to concatenate the thumbnail inside the $list. BTW im running this code inside a shortcode that's why i use a concatenate function.
$list = "";
$list = " <div class='box'> ". the_post_thumbnail('post-thumbnail') . "</div>";
the_post_thumbnail
function echoes the result and does not return anything.
If you want to concatenate it this way, you should use wp_get_attachment_image
instead.
$list .= '<div>'. wp_get_attachment_image( get_post_thumbnail_id(), 'post-thumbnail' ) . '</div>';