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 } ?>
可以根据自己的前端页面来更改html代码部分
版权声明:miqile 发表于 2022-07-08 9:46:57。
转载请注明:wordpress在首页列出所有分类及循环分类下的文章
本文固定链接:https://www.miqile.cn/3084.html
转载请注明:wordpress在首页列出所有分类及循环分类下的文章
本文固定链接:https://www.miqile.cn/3084.html
暂无评论...