If the new router uses a new IP range such as old was 192.x.x.x and the new is 10.x.x.x or such, the printer driver may not figure this out.
Also, you may have to reinstall the printer driver. Just grab the latest from HP.com and do it again.
Finally some routers BLOCK ACCESS FROM LAN TO WiFI. This one is a bit complicated and I did note it at https://www.cnet.com/forums/post/186ddf84-c102-49c4-b885-4cce74bfeb92/ but to disable this block varies with each model router.
I have an ASUS Windows 10 laptop with an HP Photosmart C5180 All-in-One printer (scanner, copier). I have the HP connected to my network through an ethernet cable connected to my wireless router/modem. The system worked fine until I switched ISP's from AT&T to RCN. I unplugged the ethernet cable from the old router and plugged it into the new one. My laptop was showing a strong connection to the new RCN network and router. I checked the printer and it showed it was offline. I ran the WIN10 printer troubleshooter and it said my printer was unavailable to the network. I tried turning on and off the printer, rebooting the laptop, and restarting the router, all to no avail. I would appreciate any solutions, links, or ideas. Thanks