Forums

Exclude category in loop (2 posts)

  1. perfectlover
    Member
    Posted 3 years ago #

    Hello,
    I have this code and I want to exclude certain categories to be exluded.

    <?php
    query_posts("cat=".$singlecatid);
    $i=0;
    while (have_posts()) : the_post();

    if($i % 2 == 0) $alt = 'odd';
    else $alt = 'even';
    $i++;

    ?>

    Thanks

  2. MichaelH
    Volunteer
    Posted 3 years ago #

    I'm confused--assuming $singlecatid has a value then the query_posts is only returning the posts from one category. Right?

    Resources:
    Exclude Posts From Some Category

    But if I missed the question, maybe you are needing something like:

    $cat = get_query_var('cat');
    query_posts('cat=' . $cat);

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.