Support » Fixing WordPress » 2 Loops with excluding special category

  • Resolved c-bass

    (@c-bass)


    Hi,

    im dont get this. I want to show an post from a special category and additionally show the news from special other categories beneath it in a 2nd loop.

    I tried:

    <?php $my_query = new WP_Query('category_name=featured&showposts=1');
      while ($my_query->have_posts()) : $my_query->the_post();
      $do_not_duplicate = $post->ID;?>
        <!-- Do stuff... -->
      <?php endwhile; ?>
        <!-- Do other stuff... -->
      <?php if (have_posts()) : while (have_posts()) : the_post();
      if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
       <!-- Do stuff... -->
      <?php endwhile; endif; ?>

    It works pretty good, but the only problem is, that i can not definy categories to exclude in the 2nd continuing loop.
    How to do that? Demo: http://www.vortex-club.de/

Viewing 1 replies (of 1 total)
  • Thread Starter c-bass

    (@c-bass)

    found out myself:

    add if (in_category('9')) continue; for a category to exclude in 2nd lopp

    <?php if (have_posts()) : while (have_posts()) : the_post(); if (in_category('9')) continue; if (in_category('3')) continue;
    		  if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
Viewing 1 replies (of 1 total)
  • The topic ‘2 Loops with excluding special category’ is closed to new replies.