I’m working on a template which will use some custom-post-types & custom-taxonomies.. I’m having problems with pagination and duplicate posts.
HOME.PHP
LOOP #1
On the homepage (home.php) I have 2 Loops. The fist one shows 1 post (custom post type: Projects) which has the custom-taxonomy “Featured” assigned to it.
LOOP #2
On the second loop I have the six most recent “Projects” (Custom post type) but I dont want a duplicate from the first loop. Under the six posts I’d like a pagination
Both loops in home.php work.. but I still have that duplicate and I can’t get pagination to work..
PasteBin
-
home.php: http://pastebin.com/6ac2asue
-
functions.php: http://pastebin.com/1SK206Bh
<?php $do_not_duplicate = array(); $folio_loop = new WP_Query( array ( 'featured' => 'featured-post', 'post_type' => 'projects', 'posts_per_page' => '1', ) ); while ( $folio_loop->have_posts() ) : $folio_loop->the_post(); $do_not_duplicate[] = $post->ID; ?> <div id="featured" style="position: relative;"> <div class="featured-overlay" style="position: absolute; right: 20px; bottom: 20px; width: 165px; height: 165px; text-align: center;"> <div class="project-meta-featured"> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" > <span> <?php global $post; $text = get_post_meta( $post->ID, '_cmb_project_meta', true ); echo $text; ?> </span> <br /> <?php global $post; $text = get_post_meta( $post->ID, '_cmb_client_meta', true ); echo $text; ?> </a> </div> </div> <?php if ( has_post_thumbnail()) : ?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" > <?php the_post_thumbnail('featured'); ?> </a> <?php endif; ?> </div> <?php endwhile; ?>
I think the best way to implement this is to use
pre_get_posts
hook. Take a look at this codeThen in your home page
You’ll need to modify it a lot but it might help you achieve what you want. In here the pagination should wotrk as normal since you just modified the main page query