WordPress.org

Ready to get started?Download WordPress

Forums

Exclude Categorys from posts loop (4 posts)

  1. Randy
    Member
    Posted 6 years ago #

    I have multiple categories and i want to exclude 2 of them. My problem comes when I go to the next page of posts. All of the following lines will exclude the categories but only on the first page of post results.

    when i use the following line my 'next page' link go no where, it goes to the same page i click from.

    <?php query_posts('cat=-17,-36'); ?>

    when i use the following line my 'next page' link go no where, it goes to the same page i click from. using home.php

    <?php if ( is_home() ) {query_posts('cat=-17,-36'); } ?>

    when i use the following line my 'next page' link goes to the next page but the categories are not excluded.

    <?php if ( is_home() && !is_paged() ) { query_posts('cat=-17,-36'); } ?>

    im looking to exclude these categories through out my regular posting not just on the first page.

    Im putting these lines right before the loop. like this

    <?php if ( is_home() && !is_paged() ) {query_posts('cat=-17,-36'); } ?>
    <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>

    ??? anyone...

  2. Kafkaesqui

    Posted 6 years ago #

  3. Randy
    Member
    Posted 6 years ago #

    thanks alot that was it. infact I think ive seen that topic page before but i just didnt understand it. must have been one of those late nights.

  4. rodsherwin
    Member
    Posted 5 years ago #

    Any ideas why the work around suggested by Kafkaesqui is broken in 2.6.1?

Topic Closed

This topic has been closed to new replies.

About this Topic