Numbered pagination links reload page – no change to URL
-
I am trying to build a paginated archive sidebar using WP_Query. As the same sidebar is used on both single.php and news.php, the arguments used for the WP_Query are different.
On news.php, the pagination works perfectly, but on single.php the pagination links are present, and have the correct href values, but simply reload the page when clicked, i.e. anything beyond page 1 is inaccessible.
Just in case this is relevant, single.php makes use of the Share Buttons by AddToAny, and Social (by MailChimp) plugins. I have deactivated both, but this has not fixed the issue with pagination.
Can anyone shed some light on this for me? Code here:
<aside> <header> <h1 class="column-title">Archive</h1> <hr> </header> <div> <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // remove first four posts if this is the news main page if ( ! is_single() ) { // Save first four posts $first_four = new WP_Query ('post_type=post&orderby=date&order=desc&posts_per_page=4'); if ( $first_four->have_posts() ) : while ( $first_four->have_posts() ) : $first_four->the_post(); $skipIDs[] = $post->ID; endwhile; endif; wp_reset_postdata(); // Save all posts $args = array( 'post_type' => 'post', 'orderby' => 'date', 'order' => 'DESC', 'posts_per_page' => -1 ); $all_posts = new WP_Query($args); while ( $all_posts->have_posts() ) : $all_posts->the_post(); // Skip first four posts and save rest if ( in_array($post->ID,$skipIDs) ) { continue; }; $offset_array[] = $post->ID; endwhile; wp_reset_postdata(); // Final arguments for WP_Query $args = array( 'post__in' => $offset_array, 'paged' => $paged, 'posts_per_page' => 5 ); } else { // Args for single.php $args = array( 'post_type' => 'post', 'orderby' => 'date', 'order' => 'DESC', 'posts_per_page' => 5, 'paged' => $paged ); } $article_archive = new WP_Query($args); $max_pages = $article_archive->max_num_pages; if( $article_archive->have_posts() ) : while( $article_archive->have_posts() ) : $article_archive->the_post(); $has_image = get_the_post_thumbnail($post->ID,'thumbnail'); ?> <article class="group"> <a class="anchor-overlay" href="<?php the_permalink(); ?>"></a> <?php if( $has_image ) { echo $has_image; } else { echo "<img src='/wp-content/themes/DCSFC/images/news-calendar/news/no-image.jpg' alt='No image' />"; } ?> <div> <h3><?php the_title(); ?></h3> <time datetime="dd/MM/YYYY"><?php echo get_the_date(); ?></time> </div> </article> <?php endwhile; endif; wp_reset_postdata(); $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' => $max_pages ) ); ?> </div>
- The topic ‘Numbered pagination links reload page – no change to URL’ is closed to new replies.