WordPress.org

Ready to get started?Download WordPress

Forums

A texte before a paswword protected post ? (6 posts)

  1. lstelie
    Member
    Posted 8 years ago #

    hello

    is it possible to have a little text (a sentence or two) before the form for a protected post, note the generic one but a text customized for a specific post ?

    TIA

    Luc

  2. amory
    Member
    Posted 8 years ago #

  3. lstelie
    Member
    Posted 8 years ago #

    Thanks a lot amory

    In case someone is ine the same situation here is the solution :

    1 - fill the excerpt field (on the top of the main post text in write mode)

    2 open wp-includes/templates-function-post.php

    after
    function get_the_password_form() {
    Line 3
    Add
    the_excerpt();

    go to get_the_excerpt() (line 100)

    Comment the bloc :
    if (!empty($post->post_password)) { // if there's a password
    if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
    $output = __('There is no excerpt because this is a protected post.');
    return $output;
    }

    }

    Now when you pasword protect a post the excerpt is displayed so you can add a customized sentence

    Hope this helps

    Luc

  4. Orin
    Member
    Posted 8 years ago #

    This tip was extremely helpful, if I do say so... and I do. It's exactly what I was looking for.

    Muchos gracias, lstelie.

  5. alekone
    Member
    Posted 8 years ago #

    hi!
    I'd like to do the same with a page template, is it possible?
    I'd like to say
    IF this post is protected
    THEN display this line
    but I don't speak PHP.
    thank you!
    ale.

  6. wdekreij
    Member
    Posted 8 years ago #

    Does anyone know what's the best way to force people to register to read a specific post?

    I can't find a good way :-(

Topic Closed

This topic has been closed to new replies.

About this Topic