custom post type older posts give 404
-
I can’t seem to get WordPress to show the proper posts for my custom post type on an archive page when using
next_posts_link("older posts");
. I’m pretty new to WordPress so i’m not sure what I could be doing incorrectly.Essentially what i’m shooting for is to be able to go backward and forwards using the older posts link and newer posts link for my custom posts that I created.
What happens is, although I am able to see and click on the older posts link (and debug that I do in fact have multiple pages), it keeps giving me a 404 error.
I would really appreciate the help. Thanks in advance
<?php $pageCount = 3; //number of pages for our work section //set our post type to whatever we find out it is. So that later we can use that title to query //as well as grab the post count for that category $postType = ''; if ( is_post_type_archive('illustrations') ) { $postType = 'illustrations'; }else if(is_post_type_archive('digital-designs')){ $postType = 'digital-designs'; }else if(is_post_type_archive('weddings')){ $postType = 'weddings'; }else if(is_post_type_archive('lettering')){ $postType = 'lettering'; }else{ $postType = 'logos'; } ?> <?php //query_posts(array('post_type' => $postType)); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts( array( 'post_type' => $postType, 'posts_per_page' => 4, 'paged'=>$paged ) ); ?> <?php get_header(); ?> <div class="container"> <div class="row main-work-spacer"> <?php $postCount = wp_count_posts($postType); $archImgCount = 0; //basic loop while (have_posts() ) : the_post(); ?> <div class="col-md-4 col-xs-12"> <!--this will diplay our link to our main image with a lightbox tag so that it works properly--> <a class="thumbnail" href="<?php $feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); echo $feat_image; ?>" rel="lightbox" data-lightbox-gallery="lightbox[gallery-1]"> <?php //is there a featured image? if( has_post_thumbnail() ) { the_post_thumbnail( 'gallery-medium', array( 'class' => 'img-responsive, center-block' ) ); //we added the img-responsive and center-center block classes we will see though } ?> </a> </div> <?php $archImgCount++; //this line is to prevent an extra row from being added on our last item if($postCount->publish % 3 != 0 || $archImgCount < $postCount->publish){ //if are on our third image start a new row if($archImgCount % 3 == 0){ ?> </div> <div class="row main-work-spacer"> <?php } } endwhile; ?> </div> <!-- pagination occurs here --> <?php $additionPages = false; if($wp_query->max_num_pages > 1){ $additionPages = true; } echo $wp_query->max_num_pages; //older posts shows up but it redirect to a 404 page next_posts_link("older posts"); previous_posts_link("newer posts"); ?> <nav> <ul class="pager"> <li class="previous"><a href="#"><span aria-hidden="true">←</span> Older</a> <li class="next"><a href="#">Newer <span aria-hidden="true">→</span></a> </nav> </div> <?php get_footer(); ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘custom post type older posts give 404’ is closed to new replies.