In my wordpress blog, i use wp paginate (default plugin) for pagination. I use a custom query to list the posts. Please see this link
Everything works fine. I show six posts per page (admin setting) and the number of pages are correct. But my problem is all the pages are shown in the pagination.
i.e. 1|2|3|4|5|6|7|8|9|10|>, but I want it like this |1|2|3|4|…|10|>.
What should I do, I’m new to wordpress. Can anyone help please?
Note:
No modifications done to wp paginate plugin.
Also changed the pagination settings in backend (wp-admin) to show 3 pages front and back of the current page and it doesn’t work.
my index.php looks like this:
<?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;?>
More details: https://developer.wordpress.org/reference/functions/paginate_links/