admin管理员组文章数量:1386667
I'm trying to alter the pagination of WP so that it shows ONLY a Previous and/or Next button, and NOT the pages in between.
Using this snippet from the Codex:
<?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
) );
?>
And these parameters:
<?php $args = array(
'base' => '%_%',
'format' => '?page=%#%',
'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' => ''
); ?>
But I can't get it right! It always shows: 1 2 next or previous 1 2
And I'm trying to get this: next previous
Can this be done by altering the parameters?
I'm trying to alter the pagination of WP so that it shows ONLY a Previous and/or Next button, and NOT the pages in between.
Using this snippet from the Codex:
<?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
) );
?>
And these parameters:
<?php $args = array(
'base' => '%_%',
'format' => '?page=%#%',
'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' => ''
); ?>
But I can't get it right! It always shows: 1 2 next or previous 1 2
And I'm trying to get this: next previous
Can this be done by altering the parameters?
Share Improve this question edited Jun 28, 2013 at 12:56 Mayeenul Islam 12.9k21 gold badges85 silver badges169 bronze badges asked Jun 28, 2013 at 8:28 zandwerkzandwerk 31 gold badge1 silver badge2 bronze badges 6 | Show 1 more comment1 Answer
Reset to default 7If you don't want to use pagination on your site, don't use paginate links function. The right way to achieve this is to use next_posts_link() and previous_posts_link() functions. These output just the link to next/prev posts like you wished.
Check these: http://codex.wordpress/Function_Reference/next_posts_link http://codex.wordpress/Function_Reference/previous_posts_link
next_posts_link( 'Older posts' );
previous_posts_link( 'Newer posts' );
本文标签: Only show Previous amp Next button in Pagination
版权声明:本文标题:Only show Previous & Next button in Pagination 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744521848a2610502.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
paginate_links
! What's the context? A post loop? A gallery? Is this in the front-end or admin? – TheDeadMedic Commented Jun 28, 2013 at 8:30end_size
=> 0, andmid_size
=> 0 should solve it, if I understand you correctly (you use$args
var aspaginate_links
function argument?). – Krzysiek Dróżdż Commented Jun 28, 2013 at 8:42next_posts_link()
&previous_posts_link()
? – TheDeadMedic Commented Jun 28, 2013 at 8:53