[英]adding pagination to a foreach loop in wordpress
我正在寻找一种在我尝试使用 paginated_links(); 的类别上实现分页的方法; 功能,但它仅适用于帖子,而不适用于实际类别。 我环顾四周,似乎这比我预期的要复杂一些......
$cats = get_categories(
array('parent' => $cat->cat_ID)
);
// loop through the categries
foreach ($cats as $cat) {
echo '<div class="card">';
// setup the cateogory ID
$cat_id= $cat->term_id;
echo '<div class="card-body">';
// make images for the category
echo '<div class="card-title"><a href="' . get_category_link($cat->term_id) . '">' . $cat->name . '</a> <i class="fas fa-arrow-right"></i></div>';
echo '</div>';
// create a custom wordpress query
query_posts("cat=$cat_id&posts_per_page=3");
if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php echo '<div class="blog-list-points">' ?>
<?php // create our link now that the post is setup ?>
<a href="<?php the_title();?>">
<?php the_excerpt(); ?>
<hr>
</a>
<?php echo '</div>'?>
<?php endwhile; endif; echo ' </div> '// done our wordpress loop. Will start again for each category ?>
<?php }
// done the foreach statement ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.