在我的wordpress博客中,我使用wp paginate(默认插件)进行分页。我使用自定义查询列出帖子。请参阅this link
一切正常。我每页显示六个帖子(管理员设置),页面数量是正确的。但我的问题是所有页面都显示在分页中。
即。 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |>,但我希望它像这样| 1 | 2 | 3 | 4 | ... | 10 |>。
我应该怎么做,我是wordpress的新手。有人可以帮忙吗?
注意:
未对wp paginate插件进行任何修改。
- 醇>
还更改了后端(wp-admin)中的分页设置,以显示当前页面前后3页,但它无法正常工作。
我的index.php看起来像这样:
<?php
$paged = get_query_var('paged');
$args = array(
'post_type' => 'post',
'meta_key' => 'wpcf-fn',
'orderby' => 'meta_value',
'order' => 'ASC',
'paged' => $paged
);
$cust_query = new WP_Query( $args );
$temp = $wp_query;
$wp_query = $cust_query;
?>
<div> *** contents rendered on the page *** </div>
<div id="navigation" class="clearfix">
<?php if(function_exists('wp_paginate')) : wp_paginate(); ?>
</div>
<?php $wp_query = $temp;?>
答案 0 :(得分:3)
<?php
global $wp_query;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages,
'show_all' => FALSE, //this will make paginate not to show all links.
'end_size' => 2, //will show 2 numbers on either the start and the end list edges.
'mid_size' => 0 //so that you won't have 1,2...,3,...,7,8
) );
?>
更多详情:http://codex.wordpress.org/Function_Reference/paginate_links