繁体   English   中英

WordPress类别列表

[英]Wordpress category list

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

  • 游戏类

    • G

      • 战争机器

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

      • 几何大战

        (“几何大战”下的所有帖子都在这里)

这就是我将它们制作成wordpress时将其分类的方式,因此它们不会混淆。 但是当我尝试渲染它们时,它们仍然会起作用。 所有游戏标题(战争机器,几何战争)下的G Is下的所有帖子都应显示。我只希望帖子中包含战争工具的帖子,应该在战争设备中显示。 也不在几何大战之下。

这是我的代码:

<?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 } ?>

谢谢!

更改

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM