如何在组合的PHP/HTML中显示缩略图和标题?
我想用这个代码片段显示我的文章的标题和缩略图,但我无法这样做 我如何解决这个问题 代码如何在组合的PHP/HTML中显示缩略图和标题?,php,wordpress,thumbnails,Php,Wordpress,Thumbnails,我想用这个代码片段显示我的文章的标题和缩略图,但我无法这样做 我如何解决这个问题 代码 $featured\u img\u url=获取发布缩略图的url(获取ID(),'full'); 回音“”;?> 您的HTML中似乎有PHP代码。也许,试试这个: <div class="row"> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $featured_img_ur
$featured\u img\u url=获取发布缩略图的url(获取ID(),'full');
回音“”;?>
您的HTML中似乎有PHP代码。也许,试试这个:
<div class="row">
<?php
if ( have_posts() ) : while ( have_posts() ) : the_post(); $featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'full'); ?>
<div class="col-md-4">
<div class="card" style="width: 18rem;">
<img class="card-img-top" src="<?php the_post_thumbnail('thumbnail'); ?>
</div>
<?php echo '<h5 class=" card-title "><a href=" ' . get_permalink() .' ">' . get_the_title() . '</a></h5 >'; ?>
<p class="card-text"><?php echo get_the_excerpt(); ?></p>
<a href="<?php the_permalink(); ?>" class="btn btn-primary"> Continue Reading »</a>
</div>
<?php endwhile;
else :
_e( 'Sorry, no posts matched your criteria.', 'textdomain' );
endif;
?>
</div>
- 如果它不能解决您的问题,也许可以查看您的语法错误/警告李>
<> LI>你可以考虑缩进你的代码,它可以帮助你在不查看错误日志的情况下找到错误。李>
<div class="row">
<?php
if ( have_posts() ) : while ( have_posts() ) : the_post(); $featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'full'); ?>
<div class="col-md-4">
<div class="card" style="width: 18rem;">
<img class="card-img-top" src="<?php the_post_thumbnail('thumbnail'); ?>
</div>
<?php echo '<h5 class=" card-title "><a href=" ' . get_permalink() .' ">' . get_the_title() . '</a></h5 >'; ?>
<p class="card-text"><?php echo get_the_excerpt(); ?></p>
<a href="<?php the_permalink(); ?>" class="btn btn-primary"> Continue Reading »</a>
</div>
<?php endwhile;
else :
_e( 'Sorry, no posts matched your criteria.', 'textdomain' );
endif;
?>
</div>