In my Wordpress custom theme, a pagination giving the 404 error when loading the page above 1. I have checked out the Permalinks and other stuff but no scuccess.
Please help me to get rid off.
Here is my code.
//Loop
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'orderby' => 'date',
'post_type' => 'jobs',
'posts_per_page' => 1,
'paged' => 'paged'
);
$the_query = new WP_Query( $args );
//Pagination
$total = $the_query->max_num_pages;
$big = 999999999; // need an unlikely integer
if( $total > 1 ) {
if( !$current_page = get_query_var('paged') )
$current_page = 1;
if( get_option('permalink_structure') ) {
$format = 'page/%#%/';
} else {
$format = '&paged=%#%';
}
echo paginate_links(array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => $format,
'current' => max( 1, get_query_var('paged') ),
'total' => $total,
'mid_size' => 3,
) );
}
question from:
https://stackoverflow.com/questions/65599015/wordpress-custom-post-type-pagination-404-page-2-error 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…