我正在处理类别。php。我让我的帖子返回我想要的方式,我正在按照我想要的方式获取子类别,但现在我正在尝试添加分页,并将帖子数量限制为3篇。当我运行测试时,第四条帖子出现在页面上。我原以为只有3个,分页在底部。我不知道怎么了。根据法典,这应该是可行的。
$allcats = get_categories(\'child_of=\'.get_query_var(\'cat\'));
foreach ($allcats as $cat) :
$args = array(
\'category__in\' => array($cat->term_id)
);
$customInCatQuery = new WP_Query($args);
if ($customInCatQuery->have_posts()) :
echo \'<div class="menupageContent">\';
$terms = apply_filters( \'taxonomy-images-get-terms\', \'\' );
if ( ! empty( $terms ) ) {
foreach( (array) $terms as $term ) {
if($term->term_id == $cat->term_id) {
echo wp_get_attachment_image( $term->image_id, \'menu\' );
}
}
}
echo \'<h3>\'.$cat->name.\'</h3>\';
echo \'<ul>\';
while ($customInCatQuery->have_posts()) : $customInCatQuery->the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php
endwhile;
echo \'</ul></div><!--end menupageContent-->\';
?>
<?php else :
echo \'No post published in:\'.$cat->name;
endif;
wp_reset_query();
endforeach;
?>
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<div class="nav-previous"><?php next_posts_link( __( \'<span class="meta-nav">←</span> Older posts\', \'paradiso\' ) ); ?></div>
<div class="nav-next"><?php previous_posts_link( __( \'Newer posts <span class="meta-nav">→</span>\', \'paradiso\' ) ); ?></div>
<?php endif; ?>