wordpress在首页列出所有分类及分类下的文章

  前面我们谈了wordpress调用指定分类文章,如果想要调用所有分类的文章如何实现呢?比如在wordpress首页列出所有分类及分类下的文章,其实方法类似

<?php
    $cats = get_categories();
    foreach ( $cats as $cat ) {
    query_posts( 'showposts=10&cat=' . $cat->cat_ID );
?>
    <h3><?php echo $cat->cat_name; ?></h3>
    <ul class="sitemap-list">
        <?php while ( have_posts() ) { the_post(); ?>
        <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
        <?php } wp_reset_query(); ?>
    </ul>
<?php } ?>

  有相同需求的朋友可以试一下

posted @ 2019-08-03 23:39  ytkah  阅读(1107)  评论(0编辑  收藏  举报
IPO发家故事 网址导航 gg N / G Sitemap

部分内容来源于网络,如有版权问题请联系删除