Sanitize $attr['total'] and change numberedposts=-1 to posts_per_page=800 for a more efficient query. Hat tip kovshenin.