WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Teaser and password Authentication (7 posts)

  1. capitanjan
    Member
    Posted 7 years ago #

    I am looking to post a teaser to the post and have the post authenticated by password.

    That way i get the best from both worlds.

    Search engines can read the teaser... and only authenticated users either paid or unpaid are able to acess the post.

    Anybody has any hints??

  2. moshu
    Member
    Posted 7 years ago #

    Nope. A lot of people would like that but I haven't seen any working solution :(

  3. Kafkaesqui

    Posted 7 years ago #

    Using a plugin like my Head META Description could potentially solve the search engine side of things.

    As for posting a teaser before the password prompt, the goal is to do a bit of a runaround to the functionality hidden in the_content(). So you could locate this in your templates:

    <?php the_content(); ?>

    and modify it to:

    <?php
    $content = explode('<!--more-->', $post->post_content, 2);
    $teaser = $content[0];
    if( !empty($content[1]) && !empty($post->post_password) && (stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password) ) {
    echo apply_filters('the_content', $teaser);
    }

    the_content();
    ?>

    Keep in mind this assumes you've added the 'more' quicktag (<!--more-->) to your post. Anything before it would be considered the 'teaser.'

    EDIT: Fixed a glaring hole in my if statement. Now you can admire it...

  4. Chris_K
    Member
    Posted 7 years ago #

    Oh say now... isn't that sneaky?

    I don't need it, but I can sure admire it!

  5. capitanjan
    Member
    Posted 7 years ago #

    Thank you VERY much. I can only find the_content in archive.php

    Am i missing any other file?

  6. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    capitanjan: You should, at a minimum, have the_content in index.php. Probably you'll have it in archive, single, maybe some category files, etc. Check all the PHP files in your theme. Every theme will be different, of course, but this is the usual approach.

  7. capitanjan
    Member
    Posted 7 years ago #

    You guys rock!! Thanks a lot

Topic Closed

This topic has been closed to new replies.

About this Topic