I write this solution today as much for me as for you. I had implemented this solution a year ago but was having trouble remembering the little steps to take to make it happen.
You will find information on this topic on Hostgator here and another article here, but I prefer the approach I outline below because it works and does not require modifying the .htaccess file in your root WordPress directory.
Here are the instructions from Hostgator. Perform these steps first but don’t test them yet as you need to perform steps 2 and 3 next.
Create a file named 401.html in your favorite text editor that says only: “PASSWORD PROTECTED FOLDER – Please enter the correct username/password.” Upload this file to the root of your domain (under public_html).
(with HostGator the path is as follows:  "/home/username/.htpasswds/public_html/directoryname/passwd"
You will find several solutions to password protecting a subdirectory when WordPress is installed. I prefer the three-step method that I demonstrated above because it does not require you to modify other existing, active files.
I hope this information has helped those out there who are researching this issue. I know that it took me time to figure it out (twice) and it probably has taken you some time to research this as well.
Hopefully, I have saved you some time.
Thanks for this article. I tried a half a dozen things that were similar to this method but didn’t work. This worked perfectly. Very easy to set up. Thanks.
In order for this to work do you have to password protect the sub-directories in Cpanel? Would this solution work without doing this?