WordPress.org

Support

Support » How-To and Troubleshooting » how to edit template-functions-post.php for password protected posts?

how to edit template-functions-post.php for password protected posts?

  • Hello,

    I want to edit template-functions-post.php so that I can have some of the texts readable by public and some are hidden in the same post. Currently, when I password-protect a post, it protects the whole post. I want that, for example, the first paragraph is visible and the rest are password protected. I don’t always do this though. Sometimes I want that the whole post is password protected and other times I dont want that the whole post is password protected.

    I find this code from some site —

    $content = $pages[$page-1];
    $content = explode(‘<!–more–>’, $content, 2);
    $output = “”;
    $output .= $content[0];
    $output .= get_the_password_form();
    return $output;

    however my problem with that, for all of my previous posts (and they are many) with no “more” tag (because I want that the whole post is password protected), the whole post has now become visible.

    I’m thinking, is there a way to detect the “more” tag in a post? What im planning to do is insert that code if a post has more tag otherwise use the standard code

    $output = get_the_password_form();
    return $output;

    thanks guys and I hope to hear from you soon 🙂

  • The topic ‘how to edit template-functions-post.php for password protected posts?’ is closed to new replies.