还没有测试过这个,但给你,莱米知道它是怎么工作的。您将需要一个自己的分页链接,但这应该非常简单
//pagination
$offset = \'0\';
$no_of_posts = the_posts_per_page( false ); //Number of posts to display on each page
if (preg_match( \'/page/\', $_SERVER[\'REQUEST_URI\'] ) ) {
$uri = explode( \'/\', $_SERVER[\'REQUEST_URI\'] );
foreach ( $uri as $key => $value ) {
if ( $value == \'\' ) {
unset( $uri[$key] );
}
}
$offset = array_pop( $uri );
$sql_offset = ( $offset * $no_of_posts ) - $no_of_posts;
}
//get categories
my_category_build( array(), 0 );
//function
function my_category_build( $args, $offset = 0 ) {
//set defaults
$defaults = array(
\'type\' => \'post\',
\'parent\' => 0,
\'orderby\' => \'name\',
\'order\' => \'ASC\',
\'hide_empty\' => 1,
\'hierarchical\' => 1,
\'taxonomy\' => \'category\',
\'pad_counts\' => 1
);
//parse args
$args = wp_parse_args( $args, $defaults );
//do real work
$categories = get_categories( $args );
$cat_c = count( $categories );
for( $i=$offset; $i<$offset+2 && $i<$cat_c; $i++ ) {
//set current category object
$categories[$i] = $cat;
//drill down deeper
$args[\'parent\'] = $cat->cat_ID;
$children = get_categories( $args );
if( count( $children ) > 0 ) {
my_category_build( $args );
}
//output posts from category
$wp_query_args = array(
\'posts_per_page\' => -1,
\'post_status\' => \'publish\',
\'cat\' => $cat->cat_ID
);
$posts = new WP_Query( $wp_query_args );
foreach( $posts as $p ) {
//your output here
}
}
}