欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

wordpress列出所有分类目录下一定数量的文章

程序员文章站 2022-06-07 13:56:20
...

不影响主LOOP, 分页正常工作 限制每个分类下文章数量 列出所有分类, 不用指定 ul ?php/** * wordpress list limited number of posts group by all categories * without destroying the main hook * coded by xiaohudie * i promised i'd use English to an

  1. 不影响主LOOP, 分页正常工作
  2. 限制每个分类下文章数量
  3. 列出所有分类, 不用指定

    5, // limit number //'ignore_sticky_posts'=>1,// defult:0 not ignore 'category__in' => array($category->term_id) //use category id to hook the category parameters ); $xhdpost = get_posts( $args ); echo '

    Category: name ) . '" ' . '>' . $category->name.'

    '; foreach ( $xhdpost as $post ) : setup_postdata($post); ?>

Demo:
wordpress列出所有分类目录下一定数量的文章