Apple devices use Bonjour to communicate with the printer, such behavior will likely occur when your router does not support transferring Bonjour packets or not configured correctly to allow such communication.
Please let me know your router brand and model, I will do my best to guide you further regarding your router configuration.
Also, click the Wireless icon and then the gear icon, select Print Reports, and then Wireless Test Report.
Can you see any warning or attention listed at the top of the report?
Say thanks by clicking the Kudos thumb up in the post. If my post resolve your problem please mark it as an Accepted Solution 🙂
Be alert for scammers posting fake support phone numbers and/or email addresses on the community. If you think you have received a fake HP Support message, please report it to us by clicking on "Flag Post".