Connect with us

Password Security for a Page or Post in WordPress

solution

Password Security for a Page or Post in WordPress

We guess you are in thought to create a WordPress post just for your close friends or family members. As a content publishing platform, WordPress have some basic content visibility options. Those options will helpful for you to create Password Security for a Post or Page in WordPress.

Here we clearly presented those details for you. Have a look at the article and learn how to create Password for a Post or Page in WordPress easily.

How to Create a Password for single Page or Post in WordPress

Creating Password Security for a WordPress Page or post is not a difficult task. If you want to create a password for your post or page then follow the given methods. Here we provided 2 different methods for you. By following one of these methods, you can easily create security for single post or page on your WordPress blog or site.

Create Password Security using Visibility Option

  • First, Login to your WordPress admin access.
  • Click on all posts option under posts section.
  • Select the post to which you want to create a password protection.
  • Click on edit from that post.
  • The selected post visual editor will appear on the screen.
  • At the right side of the Visual editor, you can see Publish section.
  • Click on edit from the visibility option under publish section.
  • Select Password Protected option.
  • Enter a new password.
  • Next, click on OK button.
  • Click on Publish button to save changes.
  • Now, share that password with your friends or family members then those are able to see that post.

In this way, you can simply create a password security for a post in your WordPress site. Follow the similar method to create password security for a page.

READ  How to redirect the attachment page to the attachment file?

How to hide Password Protected Post from Homepage and Archives?

The Password protected WordPress post may appear on homepage or archives of your website. If you want to hide that password protected post completely, then follow the given step by step process.

  • Click on the Editor option from Appearance Section.
  • Next, click on Theme Functions (functions.php) file.
  • Now, the Theme Functions (functions.php) file appears on the screen.
  • Add the given code into Functions (functions.php) file.
1/ Hide password protected posts
2function exclude_protected($where) {
3    global $wpdb;
4    return $where .= " AND {$wpdb->posts}.post_password = '' ";
5}
6
7// Where to show protected posts
8function exclude_protected_action($query) {
9    if( !is_single() && !is_page() && !is_admin() ) {
10        add_filter( 'posts_where', 'exclude_protected' );
11    }
12}
13
14// Action to queue the filter at right time
15add_action('pre_get_posts', 'exclude_protected_action');
  • Next, click on update file button.
  • Now, the file is updated. Your password protected post will not appear on homepage or archives of your website.

In this simple way, you can hide Password Protected Post from Homepage and Archives. If you face any WordPress Theme Error while updating the file, then click here to get WordPress Theme Error Solutions.

Conclusion:

Hope this article useful for you to create a password security for single WordPress Page or Post. If you get any error in your WordPress site then visit our site. Here we provided the best and quick ways for resolving your WordPress Errors. Stay connected with us for a better guidance on WordPress.

Continue Reading
You may also like...

We are a WordPress plugin developer company that focuses on useful WordPress plugin creation and empowering people to earn passive incomes from their blogs. We build unique and groundbreaking plugins that will revolutionize your blog!

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

More in solution

    Sign up for our newsletter and get a free affiliate e-book!


    About Me:

    Szabi Kisded

    Hi, my name is Szabi and I'm documenting my journey selling plugins on CodeCanyon. I will show you every step of it: learning to code, plugin ideas, WordPress stuff and more. Read more…

    Mega Plugin Bundle:

    CodeCanyon Portfolio:

    Learn to Code Plugins:

    Latest Promotions:

    Recommended Theme:

    Start Your Own Blog:

    Recommended VPN Service:

    Translate Your Blog:

    AdSense Alternative:

    Best Article Spinner:

    Popular Posts:

    Latest Posts:

    To Top

    Privacy Preference Center

        Necessary

        Advertising

        Analytics

        Other