我有一个帖子循环 (index.php),它将三个帖子链接显示为标题,并且在它们上方有一个基于帖子的 slug 的幻灯片。
<div class="nuotraukos">
<?php if (have_posts()) : ?>
<?php $nuotraukos = new WP_Query('category_name=nuotraukos&showposts=3');
while ($nuotraukos->have_posts()) : $nuotraukos->the_post();
$do_not_duplicate = $post->ID; ?>
<div class="post" id="post-<?php the_ID(); ?>">
<p class="postmetadata"><?php edit_post_link(__('Edit')); ?></p>
<div class="entry">
<?php
if ( function_exists( 'meteor_slideshow' ) ) {
$slug = basename(get_permalink());
meteor_slideshow('' . $slug. '');
}
the_content('<h2>' . get_the_title() . '</h2>');
?>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
Meteor 幻灯片本身有一个循环,我假设它在第一次查询后取消了后循环。这就是为什么它只打印出一个标题(但显示了 3 次)的原因,您可以在 http://studioglamour.co.uk 中看到它.
问题是我需要在幻灯片下方显示三个不同的链接,但不知道如何解决这个问题。
最佳答案
尝试
$slug = basename(get_permalink($nuotraukos->post->ID));
...
the_content('<h2>' . get_the_title($nuotraukos->post->ID) . '</h2>');
关于php - wordpress循环无法完成posts的查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13101808/