Custom rewrite causes 404 on pagination

If anyone still has this issue (this post is quite old), I found a very helpful snippet in this blog post: https://www.grzegorowski.com/wordpress-rewrite-rules /** * Reprioritise pagination over displaying custom post type content */ add_action(‘init’, function() { add_rewrite_rule(‘(.?.+?)/page/?([0-9]{1,})/?$’, ‘index.php?pagename=$matches[1]&paged=$matches[2]’, ‘top’); }); This will ensure WP uses the pagination rule prior to the post type query rules

How to use pagination on costum post type

$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args = array( ‘post_type’=>’post’, // Your post type name ‘posts_per_page’ => 6, ‘paged’ => $paged,); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) { while ( $loop->have_posts() ) : $loop->the_post(); // YOUR CODE endwhile; $total_pages = $loop->max_num_pages; if ($total_pages > 1){ $current_page = max(1, get_query_var(‘paged’)); echo … Read more

Custom template Page 2 not working

Please modify your query as: $paged = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1; $posts_per_page = get_option( ‘posts_per_page’ ); $artPosts= new WP_Query( array( ‘post_type’ => ‘art’, ‘posts_per_page’ => $posts_per_page, ‘post_status’ => ‘publish’, ‘orderby’ => ‘title’, ‘order’ => ‘DESC’, ‘paged’ => $paged )); <?php if ( $artPosts->have_posts() ) : ?> <?php while … Read more

Post Pagination Customization (wp_link_pages) Editing Navigation

It makes all pages show “NEXT PAGE”, because you don’t tell it that it should be any different. What you need is to set that link conditionally based on which page is currently displayed: wp_link_pages( array( ‘before’ => ‘<div id=”slideshow”>’, ‘after’ => ‘</div>’, ‘next_or_number’ => ‘next’, ‘previouspagelink’ => ‘<span id=”previous” style=”display:none;”> PREVIOUS SLIDE </span>’, ‘nextpagelink’ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)