2015-11-07 76 views
2

我必须将img响应类添加到wordpress页面模板中的图像。 我的文件被命名为single-product.php。引导:将img响应类添加到缩略图

这是我的代码

<div class="col-md-6 col-xs-12" style="margin-top:35px;"> 
    <h1><?php the_title();?></h1> 
    </div> 
    <div class="col-md-6 col-xs-12"> 
    <?php the_post_thumbnail();?> 
</div> 

现在的问题是如何添加类缩略图?

请帮助我。

回答

2

the_post_thumbnail()需要两个参数,尺寸和属性的数组。你可以在阵列中设置的属性之一是类,所以一个例子是这样的

<?php the_post_thumbnail('thumbnail', array('class' => 'img-responsive')); ?> 
您可能需要更改缩略图,你想的大小

,或者你可以让它空白。一如既往搜索食品有问题的功能,它通常有答案https://codex.wordpress.org/Function_Reference/the_post_thumbnail

2

这样,

<?php the_post_thumbnail('thumbnail', array('class' => 'img-responsive')); ?> 

此外,它是不是在你的代码中使用内联样式一个很好的做法。