When writing posts, there is an option called Visibility, which is set to Public by default. If you click Edit, then you will see options such as Password Protected and Private.
Simply click on Password Protected to add a password to your post. Doing so, only the friends, family members, or users you share this password with will be able to see this post.
A private post in WordPress is visible only to logged in users with the Editor or Administrator level user role in WordPress.
The same trick works for password protecting a page in WordPress as well.
Hiding Password Protected Posts Completely From Homepage and Archives
All your password protected posts may appear among rest of your posts on the homepage, or archives of your site. If you want to hide them completely, then use this code in your theme’s functions.php or in a site-specific plugin.