Home › Forums › General Issues › Paginating results? › Reply To: Paginating results?
As referenced
Here
You have to use You have to use WP_Query class http://codex.wordpress.org/Class_Reference/WP_Query
Here is the code for the pagination
<?php while ( have_posts() ) : the_post(); ?>
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array( 'posts_per_page' => 5, 'meta_key' => 'course_date', 'order'=> 'ASC', 'orderby' => 'meta_value', 'cat' => 2 ,'paged'=>$paged);
$catpost_ = new WP_Query( $args );
if ($catpost_->have_posts() ) :
while ($catpost_->have_posts() ) : $catpost_->the_post();
?>
<!--- CONTENT --->
<?php
endwhile;
endif;
wp_reset_query();?>
<?php
$big=76;
$args = array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'total' => $catpost_->max_num_pages,
'current' => $paged,
'prev_next' => True,
'prev_text' => __('Previous'),
'next_text' => __('Next'),
'type' => 'list');
// ECHO THE PAGENATION
echo paginate_links( $args );
endwhile;
?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.