不影响主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
<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 annotate my code, and now i did it * 2013-05-08 */ global $post; $reset_post = $post; $cat =get_categories(); foreach($cat as $category) : $args=array( 'numberposts' => 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 '<h3> Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </h3> '; foreach ( $xhdpost as $post ) : setup_postdata($post); ?> <li><a href="http://xiaohudie.net/code/<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; endforeach; $post = $reset_post; // most important step to reset after postlists with offset ?> </ul>
采用zblog修改的模板,简单方便,直接解压上传到空间即可使用,页面简单,适合SEO,导航,次导航,最新文章列表,随机文章列表全部都有,网站采用扁平结构,非常适用淘宝客类小站,所有文章都在根目录下。所有需要修改的地方在网页上各个地方都有标注说明,一切在网站后台都可以修改,无须修改任何程序代码,是新手的不二选择。后台登陆地址: 域名/login.asp用户名:admin (建议不要修改)密码:adm
1
list_all_cats_posts is coded by xiaohudie. Any posts here is one hundred percent original, so please keep my link so as not to hurt this pretty girl
全网最新最细最实用WPS零基础入门到精通全套教程!带你真正掌握WPS办公! 内含Excel基础操作、函数设计、数据透视表等
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号