Title: PLEASE HELP ME: query posts???
Last modified: 4 augustus 2016

---

# PLEASE HELP ME: query posts???

 *  [ukkepurk](https://nl.wordpress.org/support/users/ukkepurk/)
 * (@ukkepurk)
 * [16 jaren, 5 maanden geleden](https://nl.wordpress.org/support/topic/please-help-me-query-posts/)
 * Problem:
 * How to create several div’s with different post categories?
 * I tried a lot, didn’t get more than this. I can create several loops, but the
   second one doesn’t dissapear when going to the page of the post. I hope you understand
   and can help me. 🙂 PLEASE!
 * Sample: [http://www.ukkepurk.nl/blog](http://www.ukkepurk.nl/blog)
 *     ```
       <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
        <?php if ( in_category('3') ) { ?>
                  <div class="post-cat-three">
        <?php } else { ?>
                  <div class="post">
        <?php } ?>
        <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
   
        <small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small>
   
        <div class="entry">
          <?php the_content(); ?>
        </div>
   
        <p class="postmetadata">Posted in <?php the_category(', '); ?></p>
        </div>
        <?php endwhile; else: ?>
   
       <p>Sorry, no posts matched your criteria.</p>
        <?php endif; ?>
   
       <?php $myquery = new WP_Query('category_name=last'); ?>
   
       <?php while ($myquery->have_posts()) : $myquery->the_post(); ?>
        <!-- Display the Post's Content in a div box. -->
        <div class="entry">
          <?php the_content(); ?>
        </div>
   
       <?php endwhile;?>
   
       <?php wp_reset_query(); ?>
       ```
   

2 reacties aan het bekijken - 1 tot 2 (van in totaal 2)

 *  [Knight Fight](https://nl.wordpress.org/support/users/patriek-jeuriens/)
 * (@patriek-jeuriens)
 * [16 jaren, 5 maanden geleden](https://nl.wordpress.org/support/topic/please-help-me-query-posts/#post-9784)
 * I’m not exactly sure what you are trying to do but i think your looking for something
   like this:
 * <?php if ( in_category(‘3’) ) { ?>
    <div class=”post-cat-three”> <?php elseif(
   in_category(‘2’) ) { ?> <div class=”post-cat-two”> <?php elseif ( in_category(‘
   1’) ) { ?> <div class=”post-cat-one”> <?php } else { ?> <div class=”post”> <?
   php } ?>
 * Could be an error in the syntax, just trying to give you an idea how to solve
   it.
 *  Moderator [Remkus de Vries](https://nl.wordpress.org/support/users/defries/)
 * (@defries)
 * Sleutelbeheer WordPress NL
 * [16 jaren, 5 maanden geleden](https://nl.wordpress.org/support/topic/please-help-me-query-posts/#post-9794)
 * het mag in het Nederlandsch hier 🙂 Ik begrijp iig nog niet wat je nu precies
   wilt. Kun je een concreet voorbeeld geven?

2 reacties aan het bekijken - 1 tot 2 (van in totaal 2)

 Het onderwerp ‘PLEASE HELP ME: query posts???’ is gesloten voor nieuwe reacties.

## Tags

 * [query_posts](https://nl.wordpress.org/support/topic-tag/query_posts/)

 * In: [Algemeen WordPress](https://nl.wordpress.org/support/forum/algemeen/)
 * 2 reacties
 * 3 deelnemers
 * Laatste antwoord van: [Remkus de Vries](https://nl.wordpress.org/support/users/defries/)
 * Laatste activiteit: [16 jaren, 5 maanden geleden](https://nl.wordpress.org/support/topic/please-help-me-query-posts/#post-9794)
 * Status: onopgelost

## Onderwerpen

### Meest populaire onderwerpen

### Onderwerpen zonder reacties

### Non-support onderwerpen

### Opgeloste onderwerpen

### Onopgeloste onderwerpen

### Alle onderwerpen
