WordPress Password Protected Pages returning 404 error fix.

For years my companies website has used WordPress’s password protection function to hide pages that we wanted people to review before going live. So to hide those posts from the main query we’ve used this code snippet.