Ondersteuning » Algemeen WordPress » 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

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

    (@defries)

    Sleutelbeheer WordPress NL

    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.