Function using get_posts() with tax_query not working when called from functions.php

For testing purposes in your functions.php file, try this –

add_action('init', 'my_test_get_all_bands', 99);
function my_test_get_all_bands(){
    echo '<pre>'; print_r(get_all_bands()); echo '<pre>';
}

As I was attempting to say in my comment to your question (and as Pieter Goosen explained rather better), if your taxonomies have not yet been registered then the tax_query portion of your get_all_bands() function will not work as the taxonomy types does not exist.

I don’t know exactly how you are adding the taxonomy, but personally I use the init hook with a priority of 1, and that is why I’ve used a priority of 99 in this example.

The long and short of it though is that your function works, you’ve proved that by using it in your templates 🙂

Hope that helps.