我正在尝试超链接WordPress博客帖子的缩略图,以链接到其单独的博客帖子(固定链接)。下面代码中的文本链接可以做到这一点,但图像部分在if/else语句中。
代码:
<div class="carousel-inner">
<?php while( $query->have_posts() ) { $query->the_post(); $post_count++; ?>
<div class="item <?php if( $post_count == 1 ) echo 'active'; ?>">
<?php
if ( has_post_thumbnail() ) {
//Permalink needed below
the_post_thumbnail( 'slider', array( 'class' => 'img-fluid' ) );
}
?>
<div class="carousel-caption">
<h6><a class="headline-links" href="<?php echo get_permalink(); ?>"><?php the_title() ?></a></h6>
<p><?php echo excerpt( 15 ); ?></p>
</div>
</div>
<?php } //wp_reset_postdata(); ?>
</div>
https://stackoverflow.com/questions/50865483
复制相似问题