Your problem is that $args['awardyear']
gets set, once, before $term
is defined and will therefore be undefined itself. Remove it from the definition of $args
and put $args['awardyear'] = $term->name;
at the top of your foreach
loop. That way it will be set correctly on each past.
Please note that this sort of use of query_posts()
is generally frowned upon; see the Codex entry for that function.