Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Pagination issue with Custom Post Types + Advanced Custom Fields Reply To: Pagination issue with Custom Post Types + Advanced Custom Fields

#170613
deeve007
Participant
<?php
// Loop filtering by ACF field
wp_reset_postdata();
$myargs = array (
  'post_type'   => 'consultations',
  'paged'       => $paged,
  'orderby'     => 'title',
  'order'       => 'ASC',
  'meta_key'    => 'archive_item',
  'meta_value'  => 'No'
);
$myquery = new WP_Query($myargs);
if($myquery->have_posts() ) :
  while($myquery->have_posts() ) : $myquery->the_post();
?>

<!-- Do you html stuff here -->

<?php
endwhile;
endif;
wp_reset_postdata();
?>

<?php if (show_posts_nav()) : ?>
<?php if ( get_previous_posts_link() ) { ?>
    <span>&lt;?php previous_posts_link('&laquo; Newer consultations') ?&gt;</span>
&lt;?php } ?&gt;
&lt;?php if ( get_next_posts_link() ) { ?&gt;
    <span>&lt;?php next_posts_link('Older consultations &raquo;') ?&gt;</span>
&lt;?php } ?&gt;
&lt;?php endif; ?&gt;