I’m trying to style password protected posts in WordPress using the following code in my functions.php. It’s giving me a ‘Page not found’ and redirects to a ‘wp-pass.php’ url. Any ideas on how to get round it would be much appreciated.
<?php add_filter( 'the_password_form', 'custom_password_form' );
function custom_password_form() {
global $post;
$label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
$o = '<form class="protected-post-form" action="' . get_option('siteurl') . '/wp-pass.php" method="post">
' . __( "" ) . '
<label for="' . $label . '">' . __( "Password Protected" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" /><input type="submit" name="Submit" value="' . esc_attr__( "Submit" ) . '" />
</form>
';
return $o;
}
?>
Correct way to customize password protected page is
Source: http://codex.wordpress.org/Using_Password_Protection#Customize_the_Protected_Text
You have written wrong
url
in action of the form which isget_option('siteurl') . '/wp-pass.php
. So you are redirected to wp-pass.php after submitting the password. So your code should be: