• Resolved mixvio

    (@mixvio)


    I’m trying to find an answer about this but no luck.

    On https://joshuameadows.com/2006/04/drama-already/ you can see that the entry is password protected.

    I want to change the text of “This post is password protected. To view it please enter your password below:” to something else, but I can’t seem to find any place to do this. It’s not in my theme as far as I can tell and I couldn’t find it going through the .php files. Any ideas?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    It’s in the template-functions-post file. However, editing it directly is not a particularly good idea (though it will work). A better way would be to recognize it in a filter on “the_content” and change it there. You can do this in a functions.php in a theme, or you can do it in a plugin. You’d do it like so:

    function change_pw_text($content) {
    $content = str_replace(
    'This post is password protected. To view it please enter your password below:',
    'New text goes here:',
    $content);
    return $content;
    }
    add_filter('the_content','change_pw_text');

    An even better way would be to create your own language file, which will let you replace any of the built-in text in WordPress, however that is more complex than a simple quick solution.

    Thread Starter mixvio

    (@mixvio)

    Thanks for the advice Otto, however I’m incredibly obtuse. :p Is there any way I can convince you to walk me through how to do said functions.php? I don’t know enough about WordPress yet to do this myself.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Look in your theme’s directory.
    If there’s no functions.php, create a new text file with that name and insert the following code into it (no blank lines before or after the code!!).
    If the file does exist, then just edit it with a text editor and add this code to it (minus the <?php and ?> lines).

    <?php
    function change_pw_text($content) {
    $content = str_replace(
    'This post is password protected. To view it please enter your password below:',
    'New text goes here:',
    $content);
    return $content;
    }
    add_filter('the_content','change_pw_text');
    ?>

    Change the “New text goes here:” to whatever you want it to be.

    Thread Starter mixvio

    (@mixvio)

    Thanks so much! This worked perfectly.

    I’ve followed these instructions and created a functions.php file in my template with the change_pw_text($content) function…

    It doesn’t seem to have any effect though? Am I missing something else?

    I got it fixed in the end ??

    Why is this “This post is password protected. To view it please enter your password below:” coming up? How do I get rid of it so there’s no password protection? I think it comes up when I edit a post from an RSS feed…is that the case? Anyone….

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Changing the form text on password protected entries’ is closed to new replies.