Hi Good friends,
I have an index page for my blog that pulls up all posts to the page. I have a group of posts i have assigned to a category named 'Diary'. I want to prevent posts in the 'Diary' category from showing up on the index(home) page.

The code in the index page that pulls up all posts is as follows

<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
        <div <?php post_class(); ?>>
        <span class="postlabel"><a href="<?php the_permalink() ?>"><span><?php the_time('d'); ?></span><?php the_time('M'); ?></a></span>
            <h2 class="post-title"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> 
                <p class="info">
                    <span class="catinfo"><?php _e('Filed in ', 'Mflat');?><?php the_category(' | ') ?></span>
                    <span class="cmtinfo"><?php comments_popup_link( __( 'Leave a comment', 'Mflat' ), __( '1 Comment', 'Mflat' ), __( '% Comments', 'Mflat' ) ); ?><?php edit_post_link(' Edit', ' &#124; ', ''); ?></span>
                </p>
            <div class="entry">
                <?php $Mflat_options = get_option('Mflat_theme_options'); ?>
                <?php if ( $Mflat_options['home_excerpt_check']== 1 ) { the_excerpt(__('&raquo; Read more','Mflat')); } else {the_content(__('Continue Reading','Mflat'));} ?>
             </div>
            <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
                <p class="infobottom">
                    <?php if(function_exists('the_views')): ?><span class="count"><?php the_views(); ?></span><?php endif; ?>
                    <?php if (has_tag()): ?><span class="tags"><?php the_tags(' '); ?></span><?php endif; ?>
                    </p>
        </div>
            <?php endwhile; ?>
        <div class="flip">
            <div class="prevpost"><?php next_posts_link(__('Older Entries', 'Mflat')) ?></div>
            <div class="nextpost"><?php previous_posts_link(__('Newer Entries', 'Mflat')) ?></div>
        </div>
    <?php else : ?>
    <div id="main">
 <h2><?php _e('Not Found', 'Mflat'); ?></h2>
</div>
    <?php endif; ?>

now i want to alter this code so that every other post is displayed EXCEPT the post belonging to the 'Diary' Category.

All contributions are warmly welcome.
Thanks

It's seems that all important code is inside functions that you didn't post, like have_posts(), the_post() and post_class()

By the code posted I think you can do the filter altering only the have_posts() function but we need to see the code so we can help.

@AleMonteiro: Thanks for the reply budy. It took me a whole stressful day to work it out with some help from other forums. I basically had to do the filtering of the posts before calling the have_post() functions. Here is the additional code that goes in just at the top section before the if conditions.

<?php
$category = get_term_by('name', 'Diary', 'category'); // get category data
$id = $category->term_id; // get the category ID

// USE THIS IF YOU WANT TO _EXCLUDE_ ALL POSTS FROM "DIARY"
query_posts($query_string . '&cat=-' . $id);

// USE THIS IF YOU WANT TO GET ALL POSTS FROM "DIARY" ONLY
// query_posts($query_string . '&cat=' . $id);
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.