How to set Post Visibility Settings

Prem Tiwari - - WordPress Snippets

Once you publish a WordPress post (or Page), it is visible to the public (by default). In WordPress terms, this means a post with a Published status has a default visibility of Public, based on the settings in the Publish box of a Edit Post Screen.

Checking Password protected reveals a text field for entering a password, that will be required to view that post. The password is limited to 20 characters.
Checking Private makes your post visible only to your site’s Users with the role of Administrator or Editor.


Password Size Limitation

You can set the maxlength to a value of 20 when replacing the password protection form as WordPress will only save the first 20 characters due to database constraints.

Add the Password Form to the Excerpt

With the get_the_password_form function, you can make the password form be the Excerpt for a password-protected post:

Hiding Password Protected Posts

Copy and paste the following code in your theme’s functions.php:

About: Prem Tiwari

Prem Tiwari is the founder of and also a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby and also he has been a regular speaker of WordPress sessions in various IT Companies.