Here is mine below code.
Now thing is that It perfectly asks the password for secured page.

But if even I add correct password. I still page asking for password.

Below is mine code.

<?php
/**
 * Template Name: Page
 *
 */
global $post; 
if ( ! post_password_required( $post ) ) {
get_header();

?>
<div id="Content">
    <div class="content_wrapper clearfix">
secured content here

</div>
</div>
<?php 

get_footer(); 
}else{
    // we will show password form here
    echo get_the_password_form();
}

1 Answer
1

I solved issue with suggestion of @TheDeadMedic.

Below is the code. As he told added while have post. I added it after header.

<?php
/**
 * Template Name: Page
 *
 */
global $post; 
if ( ! post_password_required( $post ) ) {
get_header();
while ( have_posts() ) { the_post(); }
?>
<div id="Content">
    <div class="content_wrapper clearfix">
secured content here

</div>
</div>
<?php 

get_footer(); 
}else{
    // we will show password form here
    echo get_the_password_form();
}

Tags:

Leave a Reply

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