printer prints sometimes and sometime it does not
HP printers unable to maintain wireless connection is a very common issue that many people face. You can follow these steps and let me know if it helped.
To begin, restart your computer, printer and wifi network to resolve if there are any connection errors.
Perform a wireless test run using the free HP tool, HP Print and Scan Doctor
If no problems were detected than you can try to change the name of the wireless network. Or if you have multiple wireless networks in range that are not being used, turn them off.
Other reasons could be the printer and the wireless network are too far away, try to move them closer to each other. If everything fails, visit the HP website and update the latest printer firmware for your printer. Good luck!!