The pharynx is a common passage way for both food and air, but at a certain point (i.e. at the larynx) their fates diverge. Air passes through the larynx into the trachea, and food slides posteriorly over the larynx (via the epiglottis) and into the esophagus. There are three main "guards" to prevent the aspiration of food into the airway, and they are: the epiglottis, the vestibular folds, and the true vocal folds.
The epiglottis itself, as mentioned in the jewelry post regarding the laryngeal cartilages, is a piece of leaf shaped elastic cartilage that is amply situated to cover the glottis during swallowing. When we swallow, there are a set of extrinsic muscles attached to the hyoid bone that first move the hyoid up, and then out anteriorly (1). These are known as the "elevator" muscles, some of which include the thyrohyoid, digastric, stylohyoid, and mylohyoid muscles. Since the larynx is inadvertently attached to the hyoid bone via the thyrohyoid membrane, the whole larynx follows the motion of the hyoid bone. During laryngeal elevation, the epiglottis folds posteriorly and down over the glottis, protecting the vocal folds. Once the food has slid past the larynx on the epiglottal "food slide" into the esophagus, a set of "depressor" muscles move the hyoid bone posteriorly and inferiorly back to it's resting position. Some of the muscles involved are the sternothyroid, omohyoid, and sternohyoid muscles.
As you can see, there are many structures that prevent the aspiration of food into trachea because it's very important to maintain an open airway or we wouldn't be able to breath! And this is the first and main function of the larynx, so remember this! Phonation, though extremely interesting and talked about here, is only a secondary function of the larynx. But even with all these mechanisms in place, food can still enter the trachea sometimes! That's where the cough reflex comes in, which interestingly enough, is turned off when we are unconscious(2)....but that's a post for another time.
Whew, looking into all of that was tough work. Time for another piece of cake to exercise those extrinsic laryngeal muscles because you know what they say, if you don't use it, you lose it!
____________________________________________________________________________
References:
1. McCulloch TM, Jaffe D. Head and neck disorders affecting swallowing. GI Motility online. 2006 May;do:10.1038/gimo36
2. Marieb E, Hoehn K. Human anatomy & physiology. Boston: Pearson;2013.