我想给一个页面及其子页面添加一个数字分页。这是我想创建的分页(从 Bootstrap ):
<nav>
<ul class="pagination">
<li>
<a href="#" aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</li>
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
<li><a href="#">5</a></li>
<li>
<a href="#" aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>
</nav>
这是我的代码:
<!-- block -->
<div class="row grid events-block">
<?php
$parent = $post->ID;
// query_posts('posts_per_page=15&post_type=page&post_parent='.$parent);
query_posts(array('posts_per_page'=>'1', 'post_type' => 'page', 'post_parent' => $parent, 'paged' => get_query_var('paged')));
while (have_posts()) : the_post();
?>
<!-- item -->
<div class="grid-item col-md-6 col-sm-6 col-xs-12 event-item">
<div class="date-box">
<?php echo $event_dates; ?>
</div>
<div class="event-item-text-box">
<div class="event-item-text-inner-box">
<h3 class="heading-item"><a href="#" target="_blank"><?php the_title(); ?></a></h3>
<p><?php the_excerpt(); ?></p>
</div>
</div>
</div>
<!-- item -->
<?php endwhile; ?>
<?php
// Reset the post to the original after loop. otherwise the current page becomes the last item from the while loop.
// https://codex.wordpress.org/Function_Reference/wp_reset_query
wp_reset_query();
?>
</div>
<!-- block -->
<?php $args = array(
'base' => '%_%',
'format' => '?paged=%#%',
'total' => 1,
'current' => 0,
'show_all' => false,
'end_size' => 1,
'mid_size' => 2,
'prev_next' => true,
'prev_text' => __('« Previous'),
'next_text' => __('Next »'),
'type' => 'plain',
'add_args' => false,
'add_fragment' => '',
'before_page_number' => '',
'after_page_number' => ''
); ?>
<?php echo paginate_links( $args ); ?>
但我没法让它工作知道我错过了什么吗?
2条答案
按热度按时间ttvkxqim1#
分页方式:上一页1 2 3下一页
你能试试上面的代码吗?我想它对你有帮助。
v8wbuo2f2#
这里有一个函数,有一个可爱的引导分页链接。