Acf Relationship Fields with Pagination
Hi in this post we are sharing the solution for display post via Advance Custom Field Relationship Fields with Pagination. (display Advance Custom Field Relationship Fields data with pagination ). Use the following code to display ACF Relationship Fields data with pagination. Use your post type name (post_type) and Relationship Field name (key).
<?php if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } elseif ( get_query_var('page') ) { $paged = get_query_var('page'); } else { $paged = 1; } query_posts( array( 'post_type' => 'work', 'posts_per_page' => 2, 'paged' => $paged, 'meta_query' => array( array('key' => 'wrkclient', // name of custom field <!--- Creativetweets.com ---> 'value' => '"' . get_the_ID() . '"', // <!--- Creativetweets.com ---> 'compare' => 'LIKE' )) )); if ( have_posts() ) : $count = 0; while ( have_posts() ) : the_post(); $count++;?> <!-- Content Here --> <h2 ><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2> <!-- /Content Here --> <?php endwhile; else: ?> <div class="post"> <p><?php _e('Sorry, no posts matched your criteria.') ?></p> </div><!-- /.post --> <?php endif; ?> <?php if(function_exists('wp_pagenavi')) { ?> <?php wp_pagenavi(); ?> <?php } else { ?> <div class="navigation"><p><?php posts_nav_link('∞','«« Previous Posts','Older Posts »»'); ?></p></div> <?php } ?> <?php wp_reset_query(); ?>