Connect two ESP8266 using serial connection

The WiFi code messes with software serial. I am talking about the hardware serial port, which the WiFi code does not interfere with. If you use the hardware serial port the way I suggest you do lose the USB connection, but maybe that does not matter, you have to decide on that.

I have no experience with ESP now but I would have thought it possible to do what you want with WiFi, but you will have to experiment to find what works, I can't really advise you as I have not done what you are trying to do.