未经测试,但这至少应该在正确的轨道上:
$posts_per_page = 50;
$page = ( get_query_var( \'paged\' ) ) ? get_query_var( \'paged\' ) : 1;
$offset = ( $page - 1 );
$args = array(
\'child_of\' => 504,
\'order_by\' => \'name\',
);
$categories = get_categories( $args );
for( $i = $offset * $posts_per_page; $i < ( $offset + 1 ) * $posts_per_page; $i++ ) {
$category = $categories[$i];
echo \'<a href="\' . get_category_link( $category->term_id ) . \'" title="\' . sprintf( __( "View all posts in %s" ), $category->name ) . \'" \' . \'> \'. get_the_term_thumbnail ( $category->term_id, category, $size = \'medium\', $attr = \'\') . \' </a><a href="\' . get_category_link( $category->term_id ) . \'" title="\' . sprintf( __( "View all posts in %s" ), $category->name ) . \'" \' . \'>\' . $category->name.\'</a>\';
}
unset( $category );
辅助分页方法
if( strpos( $_SERVER[\'REQUEST_URI\'], \'/page/\' ) !== false ) {
$uri = explode( \'/\', $_SERVER[\'REQUEST_URI\'] );
foreach ( $uri as $k => $v ) {
if ( $value == "" )
unset( $uri[$k] );
}
$offset = ( array_pop($uri) * $posts_per_page ) - $posts_per_page;
}
将检查URL
/page/
, 如果包含
/page/
它将去掉所有空值,并将偏移量设置为数组的最终值。这不是最优雅的解决方案,但它很有效,而且处理能力也很好