admin管理员组文章数量:1387396
I am trying to display a page featured image. Every time I use the img tag,the text after the php code (" class="headshot" >) displays below the picture on the website. See picture screenshot of picture below
<div class="bio-picture">
<img url="<?php the_post_thumbnail('full');?>" class="headshot">
</div>
I am trying to display a page featured image. Every time I use the img tag,the text after the php code (" class="headshot" >) displays below the picture on the website. See picture screenshot of picture below
<div class="bio-picture">
<img url="<?php the_post_thumbnail('full');?>" class="headshot">
</div>
Share
Improve this question
asked May 9, 2020 at 1:47
nicannlnicannl
31 bronze badge
1 Answer
Reset to default 1This is because the_post_thubmnail()
outputs an <img>
tag. So the result of your code will be something like this:
<div class="bio-picture">
<img url="<img src="thumbnail/image/url.jpg" class="wp-post-image attachment-full">" class="headshot">
</div>
Your screenshot is how the browser has chosen to handle that broken HTML.
If you want to output the post thumbnail <img>
with a custom class, use this:
<div class="bio-picture">
<?php the_post_thumbnail( 'full', array( 'class' => 'headshot' ) );?>
</div>
Also, please note that the correct attribute for the img
tag's URl is not url
, it's src
.
本文标签: imagesHTML showing after PHP code in ltimggt tag
版权声明:本文标题:images - HTML showing after PHP code in <img> tag 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744490223a2608688.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论