Paginated pages are showing correct content but pagination links are not

Static pages doesn’t work with paged query variable, they need the page variable. This is the reason why your second code block makes the query work: it uses the page var when available. However, your paginated links code always use paged: … ‘format’ => ‘?paged=%#%’, … So you are sending paged query var but looking … Read more

Combining WordPress pagination functions for archives and search results

From the Codex: To add pagination to your search results and archives, you can use the following example: <?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 … Read more

Pagination Not Displaying on Custom Term Archive

There where one or two problems with the code that I sorted out Big changes $number_of_terms = count( get_terms( ‘100list’ ) ); is replaced by $number_of_terms = wp_count_terms( ‘100list’ );. The reason is that wp_count_terms is already there to return the term count natively get_categories is replaced by get_terms as get_terms accepts the offset parameter … Read more

Custom Search Page Pagination Not Working

You’re running into a conflict between your replacement query and the default search query that’s running behind the scenes. Instead of running a new WP_Query, try modifying the default query by hooking to pre_get_posts: function wpse276396_search_filter($query) { if ( !is_admin() && $query->is_main_query() ) { if ($query->is_search) { $text = urldecode( get_query_var(‘search_text’) ); $my_products = aws_search_byozan($text); … Read more

paginate_links and query vars

Seems that the query string is coming from the base argument call to get_pagenum_link() so I have removed the query string component and re-add it with ‘add_args’. Like so: <?php echo paginate_links(array( ‘base’ => preg_replace(‘/\?.*/’, “https://wordpress.stackexchange.com/”, get_pagenum_link(1)) . ‘%_%’, ‘current’ => max(1, get_query_var(‘paged’)), ‘format’ => ‘page/%#%’, ‘total’ => $wp_query->max_num_pages, ‘add_args’ => array( ‘s’ => get_query_var(‘s’), … Read more

How to paginate attachments in a secondary query as gallery?

I’m assuming you want something like this: |———————| | content | | (static) | |———————| | gallery | | (paged) | |———————| | << pagelinks >> | |———————| In this setup your the post content stays the same, appears to be static, while the gallery is paged. This means you have the main query, showing … Read more

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

Short answer: Try ‘base’ => str_replace( $big, ‘%#%’, esc_url( get_pagenum_link( $big ) ) ), ‘format’ => ‘?paged=%#%’, Long answer: I took a look at the paginate_links() source code (v3.5.1) and there is this line (#) $link = str_replace(‘%_%’, 1 == $n ? ” : $format, $base); that is giving you the empty first page link. … Read more

WordPress Pagination Problem

When creating custom lists of posts pagination won’t happen automatically, you’ll need to pass the pagination arguments into your get_posts call. The full details can be found on the WP_Query codex page. For the query you want to be paged you’ll need to add something like ‘paged’ => (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; to your … Read more