Password Protected Page
-
Good afternoon;
I’m trying to change the text, “PASSWORD:” next to the password field on my password protected page. I want it to say, “S.L.E CODE.”
I’m not sure if it matters, but the page is off my main nav bar. To view the page, click the picture on the very bottom of the home page “enter studio.”
I’m trying to change the text next to the password field, not the default password text.
Please help!
Thank you,
Jake
-
Try adding the following to your custom or child theme’s functions.php file:
// Amend post password form function mytheme_password_form() { global $post; $label = 'pwbox-'.(empty($post->ID) ? rand() : $post->ID); $output = '<div class="password-form"> <p class="protected-text">' . __('This post is password protected. To view it, please enter your password below:', 'mytheme') . '</p> <form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post"> <p><label for="' . $label . '">' . __('S.L.E Code:', 'mytheme') . ' </label> <input name="post_password" id="' . $label . '" type="password" size="20" /> <input type="submit" name="Submit" value="' . esc_attr__('Submit', 'mytheme') . '" /></p></form></div>'; return $output; } add_filter('the_password_form','mytheme_password_form');esmi,
Thank you for the quick reply.
This happened!
Parse error: syntax error, unexpected ‘-‘, expecting ‘)’ in /home1/cowboy/public_html/wp-content/themes/kavya/functions.php on line 337
Do not edit the theme itself. First create a child theme for your changes. And add the code above to your empty child’s functions.php file preceded by
<?php.I have created a child theme for my css.
Can you please explain to me how to create a child theme
for my php?I am sorry, I am confused.
Is it as simple as creating a blank php file inside my child theme folder and pasting in the code?
Yes. The first thing added to the new functions.php file should be
<?phpfollowed by the code I posted above.I just did that and it does not seem to work.
here is my funtions.php
<?php // Amend post password form function mytheme_password_form() { global $post; $label = 'pwbox-'.(empty($post->ID) ? rand() : $post->ID); $output = '<div class="password-form"> <p class="protected-text">' . __('This post is password protected. To view it, please enter your password below:', 'mytheme') . '</p> <form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post"> <p><label for="' . $label . '">' . __('S.L.E Code:', 'mytheme') . ' </label> <input name="post_password" id="' . $label . '" type="password" size="20" /> <input type="submit" name="Submit" value="' . esc_attr__('Submit', 'mytheme') . '" /></p></form></div>'; return $output; } add_filter('the_password_form','mytheme_password_form');[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]
Just to remind,
I am trying to change the word “password” located next to the password submit field to “S.L.E. Code.”
The code I gave above should work. I’ve used it in my themes.
Okay,
So I have created a new .php file inside of my child-theme folder that also contains my style.css.
I pasted this inside of it.
<?php // Amend post password form function mytheme_password_form() { global $post; $label = 'pwbox-'.(empty($post->ID) ? rand() : $post->ID); $output = '<div class="password-form"> <p class="protected-text">' . __('This post is password protected. To view it, please enter your password below:', 'mytheme') . '</p> <form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post"> <p><label for="' . $label . '">' . __('S.L.E Code:', 'mytheme') . ' </label> <input name="post_password" id="' . $label . '" type="password" size="20" /> <input type="submit" name="Submit" value="' . esc_attr__('Submit', 'mytheme') . '" /></p></form></div>'; return $output; } add_filter('the_password_form','mytheme_password_form');[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]
then just click save changes. Is this right?
Yes – that should work.
it’s not working.
I cleared my cache and refreshed the page and it has not changed.
I don’t doubt your code. It is more than likely the way I have set up my funtions.php.
It is just a blank php file, with the above code posted in. Do I have to import the parent php as I did for css?
I’m so sorry, I am a novice.
Are you sure that your child theme is active?
How do I activate it?
yes the child theme is active
The child theme is active, but I don’t see any php in the appearance editor. I just see my css
The topic ‘Password Protected Page’ is closed to new replies.