Actually, I am 99% sure they all get medals. Same thing happens in the track relays. Only the guys who swim the finals get the medals presented during the ceremony and stand for the anthem.
They all get them. Phelps didnt swim in the Medley Relay final in Athens as he wanted to get Ian Crocker a gold as well. Phelps swam in the Prelim only.