• Resolved ta_jonathan

    (@ta_jonathan)


    So I’m running into a pagination / 404 issue with logged-in users seeing more numbered links than published posts that exist. So for example, if a logged-in user is browsing an archive page with pagination, and click on link number five they get a 404 page because they cannot view the pending posts that are unpublished, yet are somehow being factored into the pagination. How can I modify my existing code in order to solve this? Thanks.

    // Pagination
    function ta_page_navi() {
    	global $wp_query;
    	$bignum = 999999999;
    	if ( $wp_query->max_num_pages <= 1 )
    		return;
    	echo '<nav class="pagination">';
    
    		echo paginate_links( array(
    			'base' 			=> str_replace( $bignum, '%#%', esc_url( get_pagenum_link($bignum) ) ),
    			'format' 		=> '',
    			'current' 		=> max( 1, get_query_var('paged') ),
    			'total' 		=> $wp_query->max_num_pages,
    			'prev_text' 	=> '←',
    			'next_text' 	=> '→',
    			'type'			=> 'list',
    			'end_size'		=> 3,
    			'mid_size'		=> 3
    		) );
    
    	echo '</nav>';
    } /* end pagination */

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

  • The topic ‘Excluding certain post status's from pagination’ is closed to new replies.