Forums

[resolved] 2 Loops with excluding special category (2 posts)

  1. c-bass
    Member
    Posted 4 years ago #

    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/

  2. c-bass
    Member
    Posted 4 years ago #

    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); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic