I’m making a template that shows all the users of a CPT Family like this:
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : ?>
<?php the_post(); ?>
$marriage = get_field( 'length_of_marriage' );
$relationship = get_field('relationship');
$nickname = get_field('nickname');
<?php endwhile; ?>
<?php endif; ?>
<?php echo get_next_post_link( '%link', '<i class="far fa-angle-right"></i>' ); ?>
<?php echo get_previous_post_link( '%link', '<i class="far fa-angle-left"></i>' ); ?>
But I need to display only those with "Retained" status when paging and only one item per page should be displayed.
I tried with the following code but the pager does not work, it shows me any family without respecting the query.
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array (
'post_type' => array( 'family' ),
'paged' => $paged,
'posts_per_page' => 1,
);
$args['meta_query'][] = array(
array(
'key' => 'status',
'value' => 'Retained',
'compare' => '='
)
);
$the_query = new WP_Query( $args );
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : ?>
<?php $the_query->the_post(); ?>
<?php
echo get_field('status');
echo ' '.get_field('family_id');
?>
<?php $profile_pic = get_field( 'profile_picture' ); ?>
<img src="<?php echo esc_url( $profile_pic['sizes']['family_large_thumb'] ); ?>" width="300px" height="300px" style="display:block;" />
<?php endwhile;
<?php echo get_next_post_link( '%link', '<i class="far fa-angle-right"></i>' ); ?>
<?php echo get_previous_post_link( '%link', '<i class="far fa-angle-left"></i>' ); ?>
//Clean up after the query and pagination.
wp_reset_query();
in the status bar it shows the following link but without respecting the query but when pressing the pager it does nothing.