Problem with multiple custom type post loop and pagination
-
Hi!!
I’ve a problem with a loop. It’s made-up with multiple custom type post, and pagination doesn’t work fine.
I want a pagination for all custom type post, not for each one.Code:
$paged2 = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; $args = array('post_type' => array('activities', 'conference','post'),'paged' => $paged2,'posts_per_page' => 5); $the_query = new WP_Query($args); if ($the_query->have_posts()): while ($the_query->have_posts()): $the_query->the_post(); ?> <?php $press = get_field(ICL_LANGUAGE_CODE . '_press'); $documents = get_field(ICL_LANGUAGE_CODE . '_documents'); $program = get_field(ICL_LANGUAGE_CODE . '_programs'); if($press || $documents || $program){?> <h1 class="entry-title single-title" itemprop="name"><?php echo get_the_title(); ?></h1> <?php } ?> <?php endwhile; echo '<nav>'; echo '<div>'.get_next_posts_link('Older', $the_query->max_num_pages).'</div>'; //Older Link using max_num_pages echo '<div>'.get_previous_posts_link('Newer', $the_query->max_num_pages).'</div>'; //Newer Link using max_num_pages echo "</nav>";
Thx!!!!
- The topic ‘Problem with multiple custom type post loop and pagination’ is closed to new replies.