WordPress.org

Forums

Exclude all posts from a specific category from being displayed on index.php? (11 posts)

  1. timyang
    Member
    Posted 10 years ago #

    I'd like to exclude all posts labeled under a specific category, say it's called 'personal', from being displayed within the loop on the home page (ie index.php). Could someone point me to the tutorial or template tag page that shows me how to do that. Thanks!

  2. Beel
    Member
    Posted 10 years ago #

    Do a quick search - there are plenty of threads that tell how. (can't remember off hand)

  3. acousticdryad
    Member
    Posted 10 years ago #

    I'm looking for the same thing, but the threads don't seem to help that I've searched through. They're all slightly different.

  4. oriecat
    Member
    Posted 10 years ago #

    I use the Front Page Cats plugin to do this.

  5. timyang
    Member
    Posted 10 years ago #

    Folks I found it! The problem with the Codex is that it has hidden gems inside that we have to scroll down lots to find them. ;-) Once I found this one, I realised that so many more were hidden in the "examples".

    The link is here: http://codex.wordpress.org/The_Loop#Exclude_Posts_From_Some_Category

    The Codex doesn't have a Tips and Tricks section where it gathers all these handy examples. I wish it did. I hope the link was of some help to you guys.

  6. acousticdryad
    Member
    Posted 10 years ago #

    I am getting the following error when I use this codex:
    Parse error: parse error, unexpected T_ENDWHILE in /home2/acousti/public_html/wp/wp-content/themes/myzen/index.php on line 30

    This is what I have laid out:

    <?php get_header(); ?>

    <?php if (have_posts()) : ?>

    <?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('21') && is_home()) ) { ?>

    <div class="entries">
    <span class="title">
    <?php the_title(); ?><br>
    </span>

    <div class="date">
    <?php the_time('F') ?><br><?php the_time('jS') ?><br><?php the_time('Y') ?>
    </div>

    <?php the_content('Read the rest of this entry »'); ?>

    <div align="center">
    " rel="bookmark" title="Permanent Link to <?php the_title(); ?>">Link | Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit','','|'); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
    </div>

    </div>

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

    <?php get_footer(); ?>

  7. acousticdryad
    Member
    Posted 10 years ago #

    Bump. Any clue what might be causing the error? I've messed with it unsuccessfully.

  8. Joshua Sigar
    Member
    Posted 10 years ago #

    Try the delete the first occurence of the following.
    <?php if (have_posts()) : ?>

  9. flakkito
    Member
    Posted 10 years ago #

    Try this plugin:
    Plugin Name: Category Visibility
    Plugin URI: http://www.gudlyf.com/archives/2005/03/08/wordpress-plugin-category-visibility/

    It works perfectly with 1.5.3 and you dont have to muck up your source code. It has a few extras which are handy too.

  10. acousticdryad
    Member
    Posted 10 years ago #

    Alright, I got the exclude to work, finally, with some adjustments. But I've tried to modify it to do an include of the latest post of a specific category and am not having any luck. Anyone know how to do this? I've been able to display the last post as a permalink, but I want to display the last post (entire post) of a specific category.

  11. acousticdryad
    Member
    Posted 10 years ago #

    Nevermind, I just answered my own question. For those who may be looking for the same thing, try here:
    http://codex.wordpress.org/The_Loop#Multiple_Loops_Example_1

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.