When you add a password to a WordPress
Our approach helps to correct the sometimes poor translation.
There are two methods to change the text of a password-protected page:
Plugin – “Change Password Protected Message”
The text can be changed with this plugin
Change Password Protected Message
https://wordpress.org/plugins/change-password-protected-message
Code customization in the functions.php
The message can be changed by code. You must insert this code into the “functions.php” file of the active theme.
function my_custom_password_form() {
global $post;
$label = 'pwbox-' . ( empty( $post->ID ) ? rand() : $post->ID );
$output = '
<div class="boldgrid-section">
<div class="container">
<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="form-inline post-password-form" method="post">
<p>' . __( 'This content is password protected. This is a custom message. To view it please enter your password below:' ) . '</p>
<label for="' . $label . '">' . __( 'Password:' ) . ' <input name="post_password" id="' . $label . '" type="password" size="20" class="form-control" /></label><button type="submit" name="Submit" class="button-primary">' . esc_attr_x( 'Enter', 'post password form' ) . '</button>
</form>
</div>
</div>';
return $output;
}
add_filter('the_password_form', 'my_custom_password_form', 99);
You can customize this text in the code above:
“‘This content is password protected. This is a custom message. To view it please enter your password below:”
Dieser Beitrag ist auch verfügbar auf:
Deutsch (German)