Site icon Hip-Hop Website Design and Development

Next / previous posts link doesn’t show up with Posts 2 Posts

I am working on a WordPress project where I use the Posts 2 Posts plugin to show posts from one post type to posts from another post type.

This works great but for some reason my next_posts_link() and previous_posts_link() doesn’t show up.

I have specified the paged variable in my code so it should work.

Can anyone see what I am doing wrong?

$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$connected = new WP_Query( array(
    'connected_type' => 'services_to_companies',
    'connected_items' => get_queried_object(),
    'paged' => $paged,
    'posts_per_page' => 3
));

if ( $connected->have_posts() ) { ?>

<?php while ( $connected->have_posts() ) : $connected->the_post(); ?>

<div class="company_preview box_shadow">        
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>          
</div><!--End company_preview-->

<?php endwhile; ?>

<?php if ( $connected->max_num_pages > 1 ) {
$current_page = $paged;
$total_pages = $connected->max_num_pages;
?>

<div id="nav-above">
    <div class="nav-next bx-next"><?php next_posts_link( 'Next &rarr;' ); ?></div>
    <div class="number"><?php echo $current_page . ' / ' . $total_pages; ?></div>
    <div class="nav-previous bx-prev"><?php previous_posts_link( '&larr; Previous' ); ?></div>
</div>
<?php } ?>

<?php wp_reset_postdata(); } ?>