Beginner’s GuideBlog

How to Password Protect a Page or Post in WordPress

Have you ever ever considered making a weblog publish only for shut mates or relations? Or publish a publish only for editors in your WordPress website? As a content material publishing platform, WordPress comes with some primary content material visibility choices that almost all saviours overlook. On this article, we’ll present you methods to create a password protected web page or publish in WordPress.

When writing posts, there’s an choice referred to as Visibility, which is about to Public by default. When you click on Edit, then you will note choices equivalent to Password Protected and Personal.

Making posts Private or Password Protected in WordPress

Merely click on on Password Protected so as to add a password to your publish. Doing so, solely the chums, relations, or customers you share this password with will be capable of see this publish.

A personal publish in WordPress is seen solely to logged in customers with the Editor or Administrator stage person function in WordPress.

The identical trick works for password defending a web page in WordPress as properly.

Hiding Password Protected Posts Utterly From Homepage and Archives

All of your password protected posts could seem amongst remainder of your posts on the homepage, or archives of your website. If you wish to conceal them utterly, then use this code in your theme’s capabilities.php or in a site-specific plugin.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Cover protected posts
perform exclude_protected($the place) {
    world $wpdb;
    return $the place .= " AND {$wpdb->posts}.post_password = '' ";
}
// The place to show protected posts
perform exclude_protected_action($question) {
    if( !is_single() && !is_page() && !is_admin() ) {
        add_filter( 'posts_where', 'exclude_protected' );
    }
}
// Motion to queue the filter on the proper time
add_action('pre_get_posts', 'exclude_protected_action');

That’s all. Your protected posts is not going to seem within the website’s homepage or archives. You may ship the publish’s URL to customers with the password.

We hope this text helped you password shield posts in WordPress. You may additionally need to take a look at methods to make a whole WordPress site password protected with out person registration.

Download The WPSaviour App Now

Related posts
BlogTutorials

How to Hide Password Protected Posts From WordPress Loop

Beginner’s GuideBlog

How to Make Your WordPress Blog Completely Private

Beginner’s GuideBlog

How to Password Protect a Page or Post in WordPress

Leave a Reply

Your email address will not be published.

Pay in your preferred currency
Indian rupee
Euro