Adding pagination
-
I am trying to get pagination to work on my custom post type archive, but when I click the link to the next page, the same 10 posts show up. I’ve been scouring the Internet for solutions, but don’t know how to integrate them with my particular code.
<?php if(is_single()){ ?> <?php while ( have_posts() ) : the_post('orderby=menu_order&order=asc'); ?> <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1> <div class="postContent"><?php the_content(); ?></div> <?php endwhile; ?> <?php }else { ?> <?php query_posts( 'post_type=projects' . '&orderby=menu_order&order=asc'); ?> <?php while ( have_posts() ) : the_post('orderby=menu_order&order=asc'); ?> <div class="postWrapper"> <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1> <?php $args = array( 'order' => 'ASC', 'orderby' => 'menu_order', 'post_type' => 'attachment', 'post_parent' => $post->ID, 'post_mime_type' => 'image', 'post_status' => null, 'size' => 'full', ); $attachments = get_posts($args); if ($attachments) { foreach ($attachments as $attachment) { ?> <a href="<?php the_permalink(); ?>"> <img src="<?php echo wp_get_attachment_url($attachment->ID); ?>" /> </a> <?php } } ?> </div> <?php endwhile; ?> <?php }; ?> </div> <?php /* Display navigation to next/previous pages when applicable */ ?> <?php if ( $wp_query->max_num_pages > 1 ) : ?> <div id="nav-below" class="navigation"> <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Next page', 'twentyten' ) ); ?></div> <div class="nav-next"><?php previous_posts_link( __( 'Previous page <span class="meta-nav">→</span>', 'twentyten' ) ); ?></div> </div><!-- #nav-below --> <?php endif; ?>
This was coded by a previous developer, I apologize in advance if it’s a bit sloppy.
Thanks.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Adding pagination’ is closed to new replies.