Support » Plugins » Hacks » Change my "If password required" function. STUCK!

  • I am desperately trying to change this message: “There is no excerpt because this is a protected post” on the index page into showing the actual password form, WITHOUT having to click into the actual post.

    Have been trying for a loong time now, but i seem to do something wrong as as soon as i change something, my whole wordpress page turns blank.

    This is what i have:

    if ( post_password_required() ) {
    return __( ‘There is no excerpt because this is a protected post.’ );
    }

    return apply_filters( ‘get_the_excerpt’, $post->post_excerpt );
    }

    And i want this text to turn into SHOWING THE PASSWORD FORM.

    Been trying for 2 days now. I am totally stuck 🙁

Viewing 11 replies - 1 through 11 (of 11 total)
  • I found this page: http://justintadlock.com/archives/2009/06/24/showing-the-post-password-form-for-excerpts-in-wordpress

    And added the code into functions.php.. But its still not happening :/

    If i change to the theme Twentyfourteen i get this form up as i want it to. But not on my custom theme (made with artisteer).. This is really annoying, what do i need to change/add to my custom theme to get this up like i do on “Twentyfourteen” ? 🙁

    So i have been comparing the different functions.php files from the themes, plus the post-template.php.. But i am still lost, I don’t know what to change, how, and where. It will make me SUPER happy if someone can point me in the right direction!

    WPyogi

    (@wpyogi)

    Forum Moderator

    If i change to the theme Twentyfourteen i get this form up as i want it to. But not on my custom theme (made with artisteer)..

    Have you asked on the Artisteer forums?

    http://www.artisteer.com/?p=forums

    Made a post on there now. Grrr.. this is soo annoying and i have been trying to sort this out for the past 2 days…

    Thanks for your answer, WPyogi.

    No answer on there 🙁

    Does anyone know what file i need to edit? The theme itself, functions.php, or do i have to change post-templates? I have tried but i am lacking php expirience so i cant seem to get it right.

    What i want to do is to post my_password_form at the front page. Seems like my theme is coded to not do this for some reason..

    Moderator bcworkz

    (@bcworkz)

    Filters do not work because of the way your code is structured. Instead add the filter code directly to your code. Try changing

    if ( post_password_required() ) {
    return __( 'There is no excerpt because this is a protected post.' );
    }

    to

    if ( post_password_required() ) {
       $content = get_the_password_form();
       return $content;
    }

    Tip: The blank white screen you get is because of a PHP error. It may be just a simple syntax error. To get an indication of what and where the error is, in wp-config.php, change false to true in this line:
    define('WP_DEBUG', false);

    It’s usually near the bottom above ‘/* That’s all, stop editing! Happy blogging. */’. Setting it as true is a slight security risk, so don’t forget to restore the false value when you’re done.

    I’ve used an Artisteer theme. Created a password protected page, worked fine. Then I added some test JavaScript and the password no longer protected access to the page. Once I removed the JavaScript and changed the password to a new one, it looks fine again and operated. I’m still learning JavaScript. Is this something similar and tied to using an Artisteer theme or something else?

    WPyogi

    (@wpyogi)

    Forum Moderator

    @4795209 – please don’t hijack other people’s threads – that’s not cool here – looks like you have your own here:

    http://wordpress.org/support/topic/question-about-learning-javascript?replies=1

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Change my "If password required" function. STUCK!’ is closed to new replies.