paginate_links and query vars

I have using the WordPress paginate_links() to build a paginator on a custom archive template for a custom post type. My site uses permalinks: <?php echo paginate_links(array( ‘base’ => get_pagenum_link(1) . ‘%_%’, ‘current’ => max(1, get_query_var(‘paged’)), ‘format’ => ‘page/%#%’, ‘total’ => $wp_query->max_num_pages, )); ?> This works fine until I try to add query string vars … Read more

How to paginate attachments in a secondary query as gallery?

I have this code that shows all images attached to my post-type. Is there a way to paginate those? I have like 25 pics and I wan’t to avoid scroll as much as I can. Code: <div class=”galleries ten columns”> <?php $attachments = get_posts( array( ‘post_type’ => ‘attachment’, ‘post_mime_type’=>’image’, ‘posts_per_page’ => -1, ‘post_status’ => ‘any’, … Read more

Strange paginate_links behavior. First page link is always whatever page I’m on, all other links are correct

I’m using the following code to generate some pagination: $wp_query = new WP_Query(); $wp_query->query(‘posts_per_page=5′.’&paged=’.$paged); $big = 999999999; echo ‘<div class=”pagination”>’; echo paginate_links(array( ‘base’ => ‘%_%’, ‘format’ => str_replace($big, ‘%#%’, esc_url(get_pagenum_link( $big ))), ‘current’ => max( 1, get_query_var(‘paged’) ), ‘total’ => $wp_query->max_num_pages, ‘end_size’ =>4, ‘type’ => ‘list’)); echo ‘</div>’; Its generating my links correctly on the … Read more

Paginate links with “ugly” and “pretty” permalinks?

If I have “pretty” permalinks enabled my code will work for static pages (will work if page is set as “home page” or “normal page” ). But my code breaks if I use “default permalink” structure. I have this so far (working nice with “pretty permalinks” but breaks with “ugly permalinks”): /*Declared above the loop*/ … Read more

paginate_links() don’t properly work in search.php?

I’m using this in my search.php template … <div class=”pagination”> <?php echo get_pagination_links(); ?> </div> And this is the function … function get_pagination_links() { global $wp_query; $big = 999999999; return 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, … Read more

Paginate Link generate additional #038; whenever my Url have multiple Query String

My generated paginate link results will have additional #038; in the url, may I know how to get rid of it? Blog page url : http://localhost/wordpress/blog/ I had already setup pagination with function paginate_links, when I press page [2] : Blog page Page 2 url : http://localhost/wordpress/blog/page/2/ ( everything is fine above ) However, whenever … Read more

How to remove_query_arg() for paginate_links()

I implemented a pagination using paginate_links() like below: <?php function wpse229670_pagination( $query = false ) { global $wp_query; $query = $query ? $query : $wp_query; $total_pages = $query->max_num_pages; $big = 999999999; if ( $total_pages > 1 ) { echo ‘<nav class=”navigation posts-navigation” role=”navigation”>’; echo ‘<strong>’. __( ‘Pages:’, ‘text-domain’ ) .'</strong> ‘; echo paginate_links( array( ‘base’ … Read more

Paged posts – how to use numbers and next/previous links?

I want wp_link_pages (mutli-page posts) to display the page numbers, the word “previous” before those numbers, and a “next” after those numbers. It would look like this: Prev 1, 2, 3, 4 Next I’m attempting to do this without a plugin. Here’s what I’ve tried so far, but it isn’t working, it is only displaying … Read more