WP Query ‘posts_per_page’

You add the necessary parameters to ask only for posts with the relevant clinic ID.

e.g.

$q = new WP_Query( [
    'post_type'  => 'doctors',
    'meta_key'   => 'clinic_id',
    'meta_value' => get_queried_object_id(),
] );

However, you have a fundamental mistake in how the data structure is designed. Filterable fields are supposed to be stored as terms/taxonomies, not post meta.

Post meta is built to be fast when you already know the ID of the post, but you don’t know the ID here, that’s what you’re querying for. This makes this query extremely expensive and slow. The server will struggle under moderate or even light load without a great caching system, and will have fundamental problems if you reach thousands of posts ( of all types combined not just doctors), possibly more.

Instead, use a taxonomy to store the clinic IDs, where the term slug is the ID. Don’t use post meta for it.

Here is code that will automatically create the term when a clinic is created:

add_action( 'save_post', function ( $post_id, $post ) {
    $post_type = get_post_type( $post_id );

    // If this isn't a 'clinic' post, skip
    if ( 'clinic' != $post_type ) {
        return;
    }
    wp_insert_term( $post->post_title, 'clinics', [
        'slug' => $post_id
    ]);
} );

This will delete the term when the clinic is deleted:

add_action( 'before_delete_post', function ( $post_id ) {
    $post_type = get_post_type( $post_id );

    // If this isn't a 'clinic' post, skip
    if ( 'clinic' != $post_type ) {
        return;
    }
    $term = get_term_by( 'slug', strval( $post_id ) ,'clinics' );
    if ( false !== $term ) {
        wp_delete_term( $term_id, 'clinics' );
    }
} );

This function will convert a post from post meta to using the taxonomy:

function wpse276842_convert_clinic_meta_to_terms( $post_id ) {
    $clinic_ids = get_post_meta( $post_id, 'clinic_id', false );
    if ( empty( $clinic_ids ) ) {
        return; // none were found!
    }
    $slugs = [];
    foreach ( $clinic_ids as $id ) {
        $slugs[] = strval( $id );
    }
    wp_set_object_terms( $post_id, $slugs, 'clinics', true );
}

If you want to retrieve which clinics a post/doctor appears in:

$terms = wp_get_object_terms( $post_id, 'clinics' );
foreach( $terms as $term ) {
    echo '<p>'.$term->name.'</p>';
    echo get_term_link( $term, 'clinics' );
    $clinic = get_post( $term->slug ); // gets the original clinic post
}

If you want to fetch all doctors belonging to a particular clinic

$term_id = ... the post ID of the clinic...;
$q = new WP_Query([
    'post_type' => 'doctors',
    'clinics' => strval( $term_id ),
]);

tech