WordPress.org

Ready to get started?Download WordPress

Forums

Hiding posts in 2.0 (6 posts)

  1. zarastudios
    Member
    Posted 8 years ago #

    Hi. I'm upgrading to 2.0 and can't seem to find a way to hide posts from one category on the main page. Any ideas? Thanks.

  2. petit
    Member
    Posted 8 years ago #

    In your main page index.php, ther is a loop for presenting your latest posts. It starts something like this:

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

    Immediately below that line, if you put this condition:

    <?php if ( !(in_category('4')) || !is_home() ) { ?>

    you will exclude posts from category number 4 form sjowing up on the main page.

    What it says is:
    If it is not from category 4 or if it is not on the main page, display it.

    ( is_home = true for the main page )

  3. zarastudios
    Member
    Posted 8 years ago #

    Hi. I've tried that and I get a parse error on that line. Is there another way to do this?

  4. pati
    Member
    Posted 8 years ago #

    Did you close the if-statement with <?php }; ?> ?

  5. blackc2004
    Member
    Posted 8 years ago #

    Why don't you just use the private feature on the post/edit page?

  6. petit
    Member
    Posted 8 years ago #

    It's not so easy to just copy and paste code from the forum, and each theme may use the loop a little differently.

    A full explanation of the method I tried to introduce can be found in The Loop, here.

    Good luck!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags