On the website for my running team I have a list of all active team members. I created a custom post type called tpb_teammember which has a few custom fields, amongst which one called teammember_active. In the listing template I can easily generate the correct list using a custom query that I pass to the WP_Query object, so that the list only contains the team members which have teammember_active set to "yes".
But once inside a single team member page, the paging to the previous and next teammember page no longer respects this custom query, since the context is lost. So I have been trying several different approaches to pass once again the same custom query to the WP_Query object so that when I use previous_post_link() and next_post_link(), they only display links to the previous/next active team member...but so far I can't seem to get this working.
Here is the query that I use on the team members listing page:
$args = array( 'post_type' => 'tpb_teammember', 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page'=> -1, 'meta_query' => array( array( 'key' => 'teammember_active', 'compare' => '=', 'value' => 'yes' ) ) );
How can I apply this query to the single template so that the pagination links only display links to active team member pages?