我使用以下代码在父类别页面中显示子类别。它在一个页面中显示所有子类别。我想每页显示10个子类别。请帮助我限制类别页面中的子类别。
我的代码:
<?php
$cat = get_query_var(\'cat\');
$categories= get_categories(\'hide_empty=0&parent=\'.$cat);
if(!empty($categories)){
echo \'<div class="post-listing"><section id="list"><ul>\';
foreach ($categories as $categories_item) {
$mycat .= $category->cat_name;
echo $mycat;
echo \'<li>\';
echo \'<h2 class="post-box-title"><a href="\' . get_category_link( $categories_item->term_id ) . \'" title="\' . sprintf( __( "%s" ), $categories_item->name ) . \'" \' . \'>\' . $categories_item->name.\'</a> </h2> \';
$terms = apply_filters( \'taxonomy-images-get-terms\', \'\' );
if ( ! empty( $terms ) ) {
foreach( (array) $terms as $term ) {
if($term->term_id == $categories_item->term_id) {
print \'<div class="post-thumbnail"><a class="thumb" href="\' . esc_url( get_term_link( $term, $term->taxonomy ) ) . \'">\' . wp_get_attachment_image( $term->image_id, \'medium\' );
echo \'</div></a>\';
}
}
echo \'<p>\'. $categories_item->description; echo \'</p></li>\';
}
}
echo \'</ul></section></div>\';
}else {
?>