【问题标题】:Wordpress two loops nestedWordpress 嵌套的两个循环
【发布时间】:2011-03-11 14:28:54
【问题描述】:

我想公开一个关于在 Wordpress 中集成两个循环的问题。 我有这个滑块(来自 WP Coda Slider 插件),它调用页面:

<?php query_posts('post_type=page&orderby=title&order=asc'); ?>
<div class="scrollContainer">
<?php while (have_posts()) : the_post(); ?>
<div class="panel" id="<?php echo $post->post_name ; ?>">
<?php the_content(); ?>
</div>
<?php endwhile;?>
</div>

而且效果很好。 在一个页面内容中,我运行另一个 php Loop 来调用帖子列表,如下所示:

<?php query_posts ('post_type=post&order=desc'); ?>
<?php while (have_posts()) : the_post(); ?>
<li><a rel="group_news" href="<?php the_permalink() ; ?>"><?php the_title(); ?></a><?php echo '&nbsp;&nbsp;&nbsp;' ?><?php comments_number('No Comments','1 Comment','% Comments'); ?></li><?php endwhile;?>
<?php wp_reset_query(); ?>

并且该列表会定期在该页面中调用,更准确地说是在该滑块面板中。 不幸的是,帖子也会在下一个侧面板中被调用,因为页面必须是,替换它们。 简而言之: 面板 1:页面内容(ok) 面板 2:页面内容(好的) 面板 3:页面内容 - 第二个循环的帖子列表(好的) 面板 4:发布内容(错误) 面板 5:发布内容(错误) ...

在第 4 和第 5 面板中,我希望有第 4 和第 5 页的内容,而不是帖子!

我无法解决这个问题 非常感谢

【问题讨论】:

    标签: wordpress loops slider


    【解决方案1】:

    为什么不在第二个循环中使用 get_posts?我想它会解决你的问题:http://codex.wordpress.org/Template_Tags/get_posts

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-15
      • 2011-11-05
      • 2020-03-04
      • 1970-01-01
      相关资源
      最近更新 更多