Getting 404 For the /page/2
-
On every page i m getting 404 error page. If i m click on the next for the second page.
My code for the CPT is
<?php // WP_Query arguments global $query; $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'post_type' => 'img_gallery', 'post_status' => 'publish', 'posts_per_page' => 12, 'paged' => $paged, 'ignore_sticky_posts'=> 1, 'order'=> 'ASC', 'orderby'=> 'ID' ); // The Query $query = new WP_Query( $args ); foreach( $query->posts as $post ) : // echo "<pre>"; print_r($post); //echo print_r($post); ?> <div class="grid_3 put-left box "> <div class=" video" > <figure> <a class="fancybox" href="<?php echo wp_get_attachment_url(get_post_thumbnail_id()); ?>" data-fancybox-group="gallery" title="<?php the_title(); ?>"> <?php the_post_thumbnail( 'photos' ); ?> </a> </figure> <h2 class="videoTitle"><?php the_title(); ?> </h2> </div> </div> <?php endforeach ?> <nav class="pagination"> <?php echo custom_pagination(); ?> </nav>
The pagination function is
function custom_pagination() { global $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' => $query->max_num_pages, 'prev_next' => True, 'prev_text' => __('? Previous'), 'next_text' => __('Next ?'), 'type' => 'list', ) ); }
I m confused everything is right as i do every time but what i did wrong.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Getting 404 For the /page/2’ is closed to new replies.