我正在尝试使用the_post_thumbnail()
功能将divailail添加到div 。
我正在使用的代码如下:
<div class="sc-col sc-s12 sc-m3 sc-card sc-card-basic">
<figure>'.the_post_thumbnail(array('370', '188')).'</figure>
</div>
但是,当代码在浏览器中呈现时,代码变成了(只是占据了呈现代码的一部分):
<img width="370" height="182" src="/wp-content/uploads/2016/05/image.png">
<div class="sc-col sc-s12 sc-m3 sc-card sc-card-basic">
<figure></figure>
</div>
如您所见,图像在div
和外部渲染figure
。我的问题是为什么要这样做?因为现在我的整个布局现在都中断了,所以问题是我必须使用该函数,否则我将使用其他函数。我可以以某种方式重写函数,使其仅使用add_filter
函数返回src链接吗?
这为我解决了:
<figure><?php the_post_thumbnail(array('370', '188')); ?></figure>
正如@ChrisLear所说,the_post_thumbail()
不会返回任何字符串,并且会失败。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句