Hello Guys, today i am going to explain you simple logic on making blog page passport protected.

Step 1: select one of the page as post page. You can select this from dashboard -> setting -> reading -> post page section

display-blog

step 2: Then you need to find which template is in use to display post page. See here for template heirarchy https://developer.wordpress.org/themes/basics/template-hierarchy/

And add this following condition just before the post loop:

<?php 
if ( ! post_password_required( 226 ) ) {
  if ( have_posts() ) :
  // Start the loop. while ( have_posts() ) : the_post(); 
  //content 
  endwhile;
  wp_reset_postdata(); 
 endif; 
}

Note: Here on function parameter-post_password_required we had provided the post id of blog page ie : 226.

blog-password

Please refer this article for making page as passport protected: https://codex.wordpress.org/Using_Password_Protection.

Let me know if you have any question or queries, i will be more than glad to assist you on this stuff.

Thanks

Advertisements

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: