admin管理员组文章数量:1130349
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>";
Share
Improve this question
edited Dec 27, 2018 at 7:38
Krzysiek Dróżdż
25.6k9 gold badges53 silver badges74 bronze badges
asked Dec 27, 2018 at 6:59
j. Redj. Red
133 bronze badges
1
- Can you please share the output HTML you are getting for the above – Pratik bhatt Commented Dec 27, 2018 at 7:08
1 Answer
Reset to default 2the_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>';
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>";
Share
Improve this question
edited Dec 27, 2018 at 7:38
Krzysiek Dróżdż
25.6k9 gold badges53 silver badges74 bronze badges
asked Dec 27, 2018 at 6:59
j. Redj. Red
133 bronze badges
1
- Can you please share the output HTML you are getting for the above – Pratik bhatt Commented Dec 27, 2018 at 7:08
1 Answer
Reset to default 2the_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>';
本文标签: Using concatenate with WordPress Thumbnail
版权声明:本文标题:Using concatenate with WordPress Thumbnail 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749066085a2310836.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论