Support » Fixing WordPress » Change password protect text in a child theme?

  • edhans

    (@edhans)


    I’d like to change the text on password protected posts. The thread here seems to cover the technical details (I guess it works on WP 3.5+) but I don’t want to change my theme’s function.php file. I would rather do it in my child theme, but it has no function.php file and not sure how to use the code in the linked thread to a new file and have it work properly.

    Thanks for any assistance.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Clayton James

    (@claytonjames)

    “Unlike style.css, the functions.php of a child theme does not override its counterpart from the parent. Instead, it is loaded in addition to the parent’s functions.php. (Specifically, it is loaded right before the parent’s file.)”

    Source: http://codex.wordpress.org/Child_Themes#Using_functions.php

    leejosepho

    (@leejosepho)

    That is simple to do, and I will be at my other machine in the morning where I can post the few lines needed if you do not have it done by then.

    leejosepho

    (@leejosepho)

    Here is all I needed to add to functions.php inside my Twenty Twelve Child Theme:

    // change password message for protected page/s
    
    function change_pw_text($content) {
    $content = str_replace(
    'This post is password protected. To view it please enter your password below:',
    'Hint: Tell our system to show you, and it will.',
    $content);
    return $content;
    }
    add_filter('the_content','change_pw_text');

    edhans

    (@edhans)

    Thanks. That code worked. I didn’t have a function.php file so created one. I added:

    <?php

    to the top to get it to work but in the regular function.php file, I didn’t see a closing tag. Is there one for the <?php tag?

    Clayton James

    (@claytonjames)

    I don’t believe a closing tag is required.

    leejosepho

    (@leejosepho)

    … and if you might ever use one anyway, be sure to never have any spaces or line breaks after the close.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Change password protect text in a child theme?’ is closed to new replies.