I have implemented pagination to my wp site and pagination works correctly, but when I limit to display lets say 10 posts and I have 9 then it won't show pagination.
Is it possible to show in that case 1?
I read that paginate_links will return void if under 2, but is that somehow changeable? (string|array|void) String of page links or array of page links, depending on 'type' argument. Void if total number of pages is less than 2.
My code currently. It shows pages 1 and 2 when posts > 10, but won't show 1 if posts < 10:
global $wp_query; $args_pagination = array( 'base' => add_query_arg('paged', '%#%'), 'total' => $wp_query->max_num_pages, 'current' => $paged, 'prev_next' => false); $html .= paginate_links($args_pagination); Edit: This all function is used as shortcode to use custom pagination in random places of my site (Not random, but not in the place pagination usually is). I used query_posts for that as I honestly don't know that much about wp developement.
extract(shortcode_atts(array('limit' => 1000, 'type' => 'post'), $atts )); $paged = get_query_var('paged') ? get_query_var('paged') : 1; query_posts(array( 'posts_per_page' => $limit, 'post_type' => $type, 'order' => 'DESC', 'orderby' =>'date', 'paged' => $paged)); global $wp_query; $args_pagination = array( 'base' => add_query_arg('paged', '%#%'), 'total' => $wp_query->max_num_pages, 'current' => $paged, 'prev_next' => false); $html .= paginate_links($args_pagination); And I returned html to display it on my pre-designed box.
$wp_queryglobal? Have you done the unthinkable and usedquery_postsand now need custom pagination to fix things? Why is this being returned as a string instead of output directly? In order to find a solution we're going to need to know the surrounding context that explains the need for the function and where the values come from for the function call and its arg. Use the edit link under the question tags to add as much information as you can, the key information might even be something you consider obvious or irrelevant, oversharing is good