Extending WP Query: Custom geolocation meta values work, but tax_query breaks

I’ve discovered a solution. I don’t know if it’s the best solution, but it does work.

GROUP BY wp_posts.ID was causing my query to error out. I don’t quite understand why. In theory, my query should be returning duplicate posts without it… but it’s not. So, I’m going to push this code live as it is working as intended.

For concordance, this is the filter and corresponding function which I added to my construct function:

add_filter('posts_groupby', array($this, 'my_posts_groupby'));

function my_posts_groupby($groupby) {
    global $wpdb;
    $groupby = "";
    return $groupby;
}

For more information, read Filter GROUP BY on WP ORG codex.