WordPress.org

Ready to get started?Download WordPress

Forums

Custom query problem (2 posts)

  1. Boris
    Member
    Posted 5 years ago #

    I have a small problem with a custom query. here's the code I have so far:

    <?php $recentPosts = new WP_Query();
    $recentPosts->query('cat=1,19&showposts=6');
    while ($recentPosts->have_posts()) : $recentPosts->the_post();
    $no_duplicate_recentPosts = $post->ID; ?>
    <!-- do stuff -->
    <?php endwhile; ?>

    Now my question, how I have to adjust the

    $no_duplicate_recentPosts = $post->ID;

    so the constant includes all 6 posts from the query above?
    Later I basically want to display the next 4 posts from the same 2 categories in a separate loop, obviously without those first 6 posts with this code:

    <?php $recentPosts2 = new WP_Query();
    $recentPosts2->query('cat=1,19&showposts=10');
    while ($recentPosts2->have_posts()) : $recentPosts2->the_post();
    if($post->ID == $no_duplicate_recentPosts) continue; update_post_caches($posts); ?>
    <!-- do stuff -->
    <?php endwhile; ?>

    Thanks a lot...

  2. Boris
    Member
    Posted 5 years ago #

    Anybody!?

Topic Closed

This topic has been closed to new replies.

About this Topic