Created
September 24, 2017 16:02
-
-
Save vubon/cae3f7ef69e08c15f15b874628368aa0 to your computer and use it in GitHub Desktop.
WordPress post password form customization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Your page content display by this code | |
<?php if ( !post_password_required() ) { ?> | |
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> | |
<?php the_content(); ?> | |
<?php endwhile; endif; ?> | |
<?php } ?> | |
// Form customization in same template | |
<?php if ( post_password_required() ) : ?> | |
<form action="<?php bloginfo('wpurl'); ?>/wp-login.php?action=postpass" method="POST"> | |
<div class="form-group"> | |
<?php | |
if (isset($_COOKIE['wp-postpass_' . COOKIEHASH]) && $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) : ?> | |
?php | |
$msg = esc_html("Password is Invalid!, please try again."); | |
$msg ="<p class='error'><img src='image link'> $msg</p>"; | |
echo $msg; | |
?> | |
<?php endif ; ?> | |
<input name="post_password" type="password" class="form-control" id="password" placeholder="Enter Your Password Here..."> | |
<button type="submit" name="Submit" class="btn btn-go btn-block">Go!</button> | |
</div> | |
</form> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment