我在主题的标题中内置了一些自定义代码,可以从帖子中获取特色图片,在用户单击时永久显示图片和指向帖子的链接。
我遇到的问题是,我在两个不同的div上发生了这种情况,从两个不同的类别中提取信息,但当你作为用户悬停在链接上时,它只使用两幅图像中的一幅的永久链接。我正在使用“页面链接到”插件将帖子重定向到站点中的某个页面,所以我想知道这是否会导致问题。下面是我在两个单独分区中获取特色图像的片段:
<div id="homeprint">
<a href="<?php the_permalink(); ?>">
<?php $the_query = new WP_Query( \'cat=100\' );
// The Loop
while ( $the_query->have_posts() ) : $the_query->the_post();
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail();
}
endwhile; ?>
</a>
</div>
<div id="lookup">
<a href="<?php the_permalink(); ?>">
<?php $the_query = new WP_Query( \'cat=101\' );
// The Loop
while ( $the_query->have_posts() ) : $the_query->the_post();
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail();
}
endwhile;
// Reset Post Data
wp_reset_postdata(); ?>
</a>
</div>
我需要两份wp_reset_postdata();
还是我做错了?例如here 在标题中。您将看到两个应该链接到两个不同页面的矩形图像。现在它们都链接到同一个位置。提前谢谢大家。