Modify WP Query post__in before have_posts()

I can see several possibilities for this one.

First, I am not convinced that that you can’t use pre_get_posts though maybe you’d have to reorganize your code. You don’t have to wait for your theme template to use $_GET. Try:

function tst() {
    // global $_GET; // sometimes necessary
    var_dump($_GET);
}
add_action('pre_get_posts','tst');

So I think something like:

function finder_sort($query) {
    // I don't know what your complete code for processing $_GET is but
    // that would go here and set $pin
    if ($query->is_main_query() && is_tax(array('location_type')) && isset($_GET['finder_action'])) {
        $query->set('post__in', $pin);
    }
}
add_action('pre_get_posts','finder_sort');

That is one possibility, and from where I sit right now looks like the best one. If for some reason that isn’t possible you can always do something like:

$locations_found = wp_list_pluck($locations, 'id');
while(have_posts()) {
    the_post();
    if (in_array($post->ID,$locations)) {
        echo '<tr>';
        finder_location_teaser_table();
        echo '</tr>';
    }
}

I am assuming some things about your data. Your question doesn’t have all of the necessary information for me to write code with 100% confidence but that is the idea.

tech