Forum Replies Created

Viewing 1 replies (of 1 total)
  • Forum: Fixing WordPress
    In reply to: query_posts offset

    Hi,

    I’d like to split my loop into two divs, with 3 posts in each div. I have acheived this by using query_posts for the first loop and get_posts (which has an offset parameter) for the second. However, I would also like to exclude a certain category from both these loops, but get_posts doesn’t offer that option.

    maybe my solution solves the problem for other users as well…
    I’ve solved the problem shown above for me in that way:
    my first loop looks like this:

    <?php $my_query = new WP_Query('showposts=3');
    while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <!-- Show the first three posts in div1 -->
    <?php endwhile; ?>

    and the second loop:

    <?php
    $my_query = new WP_Query('showposts=6'); // showposts here minus the showposts from the first loop will be displayed
    while ($my_query->have_posts()) : $my_query->the_post();
    $seconddiv = $post->ID;
    if($seconddiv > 6){
    ?>
    <!-- Show the next three posts in div2 -->
    <?php endwhile; ?>

    …maybe quick & dirty – but it works. ??

    greets,
    Marc ??

Viewing 1 replies (of 1 total)