How to use simple pagination for CPTs

Use in a template partial for content-single-… are custom loops within a CPT post required to make simple pagination links to work?

App.php function:

public function infoguideLoop() {
    $career = get_posts([
        'post_type' => 'info_guide',
        'posts_per_page' => '8',
    ]);

    return array_map(function ($post) {
        return [
            'title' => apply_filters('the_title', $post->post_title),
            'content' => apply_filters('the_content', $post->post_content),
            'thumbnail' => get_the_post_thumbnail($post->ID, 'large'),
            'url' => get_post_permalink($post->ID),
            'ig-next' => get_next_posts_link($post->ID),
            'ig-prev' => get_previous_posts_link($post->ID),
        ];

    }, $career);
}

partials.content-single-info_guide:

<div class="ig-paginator">
	{!! $infoguide_loop['ig-next'] !!}
</div> 

The above breaks and displays ‘undefined index’: ig-next

The commented default wp_link_pages doesn’t throw an error, but displays nothing.

This topic was automatically closed after 42 days. New replies are no longer allowed.