Beginner’s GuideBlog

How to Password Protect a Page or Post in WordPress

Have you ever ever thought of making a weblog put up only for shut associates or relations? Or publish a put up only for editors in your WordPress web site? As a content material publishing platform, WordPress comes with some fundamental content material visibility choices that the majority saviours overlook. On this article, we’ll present you the right way to create a password protected web page or put up in WordPress.

When writing posts, there may be an choice referred to as Visibility, which is ready to Public by default. Should you click on Edit, then you will note choices reminiscent of Password Protected and Non-public.

Making posts Private or Password Protected in WordPress

Merely click on on Password Protected so as to add a password to your put up. Doing so, solely the chums, relations, or customers you share this password with will have the ability to see this put up.

A non-public put up in WordPress is seen solely to logged in customers with the Editor or Administrator stage person position in WordPress.

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

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 web site. If you wish to cover 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
// Disguise 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 won’t seem within the web site’s homepage or archives. You possibly can ship the put up’s URL to customers with the password.

We hope this text helped you password shield posts in WordPress. You may additionally need to try the right way 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 Password Protect a Page or Post in WordPress

Beginner’s GuideBlog

How to Make Your WordPress Blog Completely Private

Leave a Reply

Your email address will not be published.

Pay in your preferred currency
Indian rupee
Euro