我有一个自定义循环,显示“最受欢迎”的帖子部分。它首先创建一个链接的容器(<a href="<?php the_permalink(); ?>"> ... </a>
), 然后将当前帖子中的数据存储在该容器内的循环中。
如果帖子有缩略图,则会显示图像(if ( has_post_thumbnail() ) { the_post_thumbnail(); }
). 否则,它将执行the_content();
在else { }
部分,其中它可以抓取一个iframe并显示它。
出于某种原因,如果它进入else { }
零件,它将关闭开口<a href="<?php the_permalink(); ?>">
带结束符的语句</a>
首先标记。这导致<div class="most-popular-article"></div>
其内容在<a></a>
容器,而不是容器内部。
有人知道这里到底发生了什么,或者如何防止它发生吗?
<a href="<?php the_permalink(); ?>">
<div class="most-popular-article">
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
else {
the_content();
} ?>
<h3><?php the_title(); ?></h3>
</div>
</a>