【发布时间】:2018-07-08 17:19:32
【问题描述】:
我在尝试呈现 Wordpress 分页时遇到了一个重大问题。我对 PHP 不是很好,我已经尝试了几乎所有我能用谷歌搜索的解决方案。一些查询“有效”,因为它们显示一组页码,但是当我添加更多变量时它们会中断。
例如,当我告诉它显示所有页面时,它就是这样做的,但是我无法使用 mid_size 或任何其他方法来限制它。所以这是一种“显示所有”(我不想要),或者什么都没有。我不确定发生了什么问题,因此任何朝着正确方向的推动都会非常好。
我的目标:创建一个正确截断的编号页面链接列表,如下所示:
[1 2 3 ... 97 98 99]
感谢任何可以帮助我的人。我正在运行 Wordpress 4.9.7。
我的代码如下所示:
<!-- post loop -->
<div class="auto cell">
<?php
// the query
$wpb_all_query = new WP_Query(array('post_type'=>'review', 'posts_per_page' => 3, 'orderby'=>'name', 'order'=>'ASC')); ?>
<?php if ( $wpb_all_query->have_posts() ) : ?>
<!-- start of main news loop -->
<?php while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post(); ?>
<div class="grid-x grid-margin-x">
<div class="cell large-2 small-2">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="thumbnail">
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail();
} else { ?>
<img src="<?php bloginfo('template_directory'); ?>/img/default_thumb.png" alt="<?php the_title(); ?>" />
<?php } ?></a>
</div>
<div class="cell large-10 small-10">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<span class="post-meta"> By <?php the_author_posts_link(); ?> · <?php the_time('F jS, Y, g:i A'); ?> <?php edit_post_link(__('Edit This'), ''); ?></span>
<ul class="list-meta">
<li>Developer: <?php echo(types_render_field( 'game-developer' )); ?></li>
<li>Genre: <?php echo(types_render_field( 'game-genre' )); ?></li>
</ul>
</div>
<div class="post-categories cell"><?php the_category(', '); ?></div>
</div>
<?php endwhile; ?>
<!-- start of pagination -->
<div class="row">
<?php if (function_exists("pagination")) {
pagination($custom_query->max_num_pages);
} ?>
</div>
<!-- end of pagination -->
<!-- end of main news loop -->
【问题讨论】:
标签: php wordpress pagination