【问题标题】:Wordpress category listWordPress 类别列表
【发布时间】:2013-02-20 08:44:02
【问题描述】:

您好,我正在尝试显示某个类别下的所有帖子。看起来像这样

  • 游戏

    • G

      • 战争机器

        (游戏下的所有帖子都在这里)

      • 几何战争

        (几何战争下的所有帖子都在这里)

这就是我在创建它们时在 wordpress 中对帖子进行分类的方式,因此它们不会混淆。但是当我尝试渲染它们时它们仍然会这样做。 G下的所有帖子都显示在每个游戏标题下(战争机器,几何战争)我只想要战争机器下有任何帖子的帖子,它们应该显示在战争机器下。也不在几何战争之下。

这是我的代码:

<?php
$cat_id = get_query_var('cat');
$catlist = get_categories('hide_empty=0&child_of=' . $cat_id);
$cat_child = get_field('frontend_name' , 'category_'  . get_query_var('cat' ));

foreach($catlist as $categories_item) {
    echo "<ol>";
    echo '<h3><a href="' . get_category_link( $categories_item->term_id ) . '" ' . '>' . $categories_item->description .'</a> </h3> ';
    query_posts("cat=$cat_id&post_per_page=9999");

if (have_posts()) : while (have_posts()) : the_post(); ?>
    <li><a href="<?php the_permalink();?>">
      <?php the_title(); ?>
   </a></li>
<?php endwhile; endif; ?>
<?php echo "</ol>"; ?>
<?php } ?>

谢谢!

【问题讨论】:

    标签: php wordpress list categories


    【解决方案1】:

    改变

    query_posts("cat=$cat_id&post_per_page=9999");
    

    query_posts("cat=" . $categories_item->term_id . "&post_per_page=9999");
    

    【讨论】:

      猜你喜欢
      • 2018-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-01
      • 2014-07-02
      • 1970-01-01
      • 1970-01-01
      • 2014-12-27
      相关资源
      最近更新 更多