我是Wordpress模板和php开发的新手。我正在制作一个模板,从多个帖子中在一个页面上绘制多个帖子缩略图。我遇到的问题是,特色图片都是一样的,继承了第一篇文章的图片。下面是我的代码-如果您能帮助我在每篇帖子中包含自己的特色图片,我将不胜感激:)
<div class="col-lg-2 text-center">
<div class="soap-container tire-clean">
<?php
$post_id = 35;
$queried_post = get_post($post_id);
$featured_img_url = get_the_post_thumbnail_url($post->ID, \'full\');
?>
<a href="#" data-toggle="modal" data-target="#tireModal"><img width="100%" src="<?php echo get_the_post_thumbnail(\'35\', \'full\'); ?>"></a>
<a href="#" data-toggle="modal" data-target="#tireModal"><h3><?php echo $queried_post->post_title; ?></h3></a>
</div>
</div>
<div class="col-lg-2 text-center">
<div class="soap-container tire-clean">
<?php
$post_id = 37;
$queried_post = get_post($post_id);
$featured_img_url = get_the_post_thumbnail_url($post->ID, \'full\');
?>
<a href="#" data-toggle="modal" data-target="#tireModal"><img width="100%" src="<?php echo get_the_post_thumbnail(\'37\', \'full\'); ?>"></a>
<a href="#" data-toggle="modal" data-target="#tireModal"><h3><?php echo $queried_post->post_title; ?></h3></a>
</div>
</div>
<div class="col-lg-2 text-center">
<div class="soap-container mega-foam">
<?php
$post_id = 39;
$queried_post = get_post($post_id);
$featured_img_url = get_the_post_thumbnail_url($post->ID, \'full\');
?>
<a href="#" data-toggle="modal" data-target="#foamModal"><img width="100%" src="<?php echo get_the_post_thumbnail(\'39\', \'full\'); ?>"></a>
<a href="#" data-toggle="modal" data-target="#foamModal"><h3><?php echo $queried_post->post_title; ?></h3></a>
</div>
</div>
最合适的回答,由SO网友:Michael 整理而成
try using:
$featured_img_url = get_the_post_thumbnail_url($queried_post->ID, \'full\');