For USB printing- If the cable is more than 3 m (9 ft 10 in) in length, replace the cable with one that is shorter.
To isolate the wireless connectivity further, I'd like to know the following-
Are the printer and PC connected to the same network?
Is your router dual-band enabled i.e., both 2.4GHz and 5GHz?
What is the distance between the router and the printer?
Is there any antivirus software installed on your computer?
Could you perform a ping test using the Mac Network Utility and let me know the results?
Use the printer IP address to perform a ping test, the printer IP can be located by selecting the wireless icon on the printer display.
The wireless status menu on your Mac should also give us quite a lot of information that would help us identify the issue. You can press and hold option-click the WiFi icon and then use shift-command-5 to take the screenshot. Press the space bar when the icon turns into a camera. Share the ping test results and the screenshot with us.
Also, check with your Internet service provider if your router is able to forward 'Bonjour packets'.
Bonjour locates devices such as printers, other computers, and the services that those devices offer on a local network using multicast Domain Name System (mDNS) service records. The software comes built-in with Apple's macOS and iOS operating systems.
Keep me posted for further assistance.
Please click “Accepted Solution” if you feel my post solved your issue, it will help others find the solution. Click the “Kudos/Thumbs Up" on the bottom right to say “Thanks” for helping!
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".