Support » Fixing WordPress » Password Protected entries not show up on main page?

  • Resolved wellofdreams


    Is it possible for posts from a certain section/cetegory of your blog not show up on the main index page?

    For example, I want a certain section to contain private password protected entries, and there’s no point in having them cluttering up the main pages…

Viewing 7 replies - 1 through 7 (of 7 total)
  • You should take a look at this article in the Codex

    Thanks ^_^

    I wasn’t sure where I was supposed to put the code, so I replaced this: <?php while (have_posts()) : the_post(); ?>

    with this:
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    <!– The following tests if the current post is in category 3. –>
    <!– If it is not, the code within The Loop is executed as normal. –>
    <!– If it is, nothing is done until the next post is processed. –>
    <?php if ( !(in_category(’26’) && is_home()) ) { ?>

    <div class=”post”>

    <h2>“><?php the_title(); ?></h2>

    <small><?php the_time(‘F jS, Y’); ?></small>

    <div class=”entry”>
    <?php the_content(); ?>

    <p class=”postmetadata”>Posted in <?php the_category(‘, ‘); ?>
    </div> <!– closes the first div box –>

    <?php } ?> <!– Close the if statement. –>

    <?php endwhile; else: ?>
    Sorry, no posts matched your criteria.
    <?php endif; ?>

    But got this error:

    Parse error: parse error, unexpected T_ENDWHILE in /home/.hauser/wellofdreams/ on line 56

    How can I esclude password protected posts from main page?

    something such as “if(is_protected()) { continue; }” ?

    <?php if( $post->post_password ) { continue; } ?>

    It works!! Thanks!!

    but if I configured the main index to show the 10 latest posts, if I have one protected, it shows 9. How could I increase or decrease the counter? I mean, what var contains it?

    How could I increase or decrease the counter?

    You can’t. Anything acting on posts (i.e. The Loop) is stuck working with a pre-existing number in the $posts object because there’s no functionality letting you tell it to go back and get one more.

    The goal would be to pass over password-protected posts *before* they end up in the $posts object in the first place. For that, a simple little plugin can do the job…

    Exclude Password Posts plugin:
    Dowload plugin | View source


Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Password Protected entries not show up on main page?’ is closed to new replies.