Php 是否将特色图像显示为缩略图?
我目前正在尝试从一个类别向我的主页显示一篇文章,以及一张图片(特色图片) 到目前为止,我有一个代码可以抓取帖子并将其显示在我的主页上:Php 是否将特色图像显示为缩略图?,php,html,css,wordpress,post,Php,Html,Css,Wordpress,Post,我目前正在尝试从一个类别向我的主页显示一篇文章,以及一张图片(特色图片) 到目前为止,我有一个代码可以抓取帖子并将其显示在我的主页上: <div class="row"> <div class="col-md-6"> <?php query_posts('cat=4'); while (have_posts()) : the_post(); the_content(); endwhile;?> </div&
<div class="row">
<div class="col-md-6">
<?php query_posts('cat=4');
while (have_posts()) : the_post();
the_content();
endwhile;?>
</div>
这确实会显示,但我现在也尝试设置一个特色图像
我希望它显示为:
我看到了一些建议,例如
但我不是百分之百地想加上这个
超级感谢 您应该这样做:
<div class="row">
<div class="col-md-6">
<?php query_posts('cat=4');
while (have_posts()) : the_post();
if ( has_post_thumbnail() ) {
the_post_thumbnail('thumbnail');
}
the_content();
endwhile;?>
</div>
您可能需要使用CSS将内容和帖子缩略图包装成div和样式,或者使用主题中的列类您可以尝试这个,但未经测试。我将
args
保留为一个数组,以防您需要添加其他数组
<div class="row">
<div class="col-md-6">
<?php
$args = array( 'cat' => 4 );
$loop = new WP_Query( $args );
while ($loop->have_posts() ) : $loop->the_post();
?>
<div style="float: left;">
<?php the_post_thumbnail( 'thumbnail' ); ?>
</div>
<?php the_content(); ?>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</div>
</div>
您可以将类添加到特色图像本身——还有一个问题,我正在尝试使用我的框架将缩略图放入col-md-4,将内容放入col-md-8。这是怎么回事?当我尝试拆分PHP时,它不起作用。