Visiting Oaxaca after CDMX (Ciudad de Mexico = Mexico City) is an excellent idea, especially if you're headed towards the Yucatán Peninsula.
The distance from Mexico City to Oaxaca is about 365 kilometers (227 miles), which gives you multiple options to choose from!
Going from Mexico City to Oaxaca by bus is the cheapest an most common option chosen by travelers.
Depending on the route and company that you choose, the ride duration can vary a lot! The shortest advertised duration is 6h25 (it will probably be longer in reality), stay away from 7h+ and 8h+ routes it's just not worth it.
This route is offered by a few different companies: ADO, AU (Autobuses Unidos) and OCC. Prices range from USD15 to USD30. Some buses (OCC for sure, maybe some ADO) have restrooms, which can be very practical for a ~7h ride (even though there are some stops along the way). Tickets can be brought on the companies websites, bus comparison websites (checkmybus, clickbus) or in travel agencies. You can also find AU/ADO (actually the same company) shops, check out Google Maps for that.
Note: Oaxaca is also the name of the state which can be confusing, select Oaxaca de Juárez if available when buying tickets, it's the full Spansh name of Oaxaca City.
When buying online you'll sometimes see ES INDISPENSABLE IMPRIMIR LOS BOLETOS ANTES DE ABORDAR which means that you need to print your tickets beforehand (many shops can do that cheaply, bring a USB key or host the PDF file somewhere to access easily).
Imprimir = To print
Los boletos = The tickets
Be aware that you also have to option to make a stop in Puebla, which is right between Mexico City and Oaxaca.
If you have or rent a car, the ride will take you about 5h30 / 6h. After about 2h (taking the Carretera Federal 150D), you'll reach Puebla City. Make a stop there! It would be a shame not to visit it if you're there since Puebla is a famous spot, with plenty of things to see and do.
Take the Carretera Federal 135D to finish your ride to Oaxaca.
There are daily flights from Mexico City Benito Juarez International Airport (MEX) to Oaxaca (OAX), with Viva Aerobus, Interjet, Aeromar and Aeromexico. The flight time is 1h15.
Prices range from USD38 if you're lucky to USD180 for the high-end (the average ticket is around USD77).
Hike to the top of an unexplored hill and admire spectacular panoramic views. Discover a less touristic side of the island on a bike ride through local fisheries, markets, and neighborhoods. Connect with Stone Island Villagers to learn about their culture and traditions.
You will cook authentic Mexican dishes in a beautiful set up surrounded by a knowledgeable, English speaking Mexican chef. You will have a Brief overview of a local food market, located only one block away from the place where the cooking class will be performing.