Support » Fixing WordPress » Multiple loops for categories

  • i’m using 1.2 and i wanted to try out the new multiple loops feature
    what i’m trying to do, is to show the posts of different categories in different loops. now how do i tell the loop, to only show posts of one category?

Viewing 6 replies - 1 through 6 (of 6 total)
  • isn’t it:

    $cat = ‘1’ should identify that you want to use the category with ID=1
    the above link also shows an example of how to use in_category().
    Hope that helps.

    ok it works with the in_category function, thanks
    i’ve setup 2 loops: the first is the main loop with full text posts, and the second shows only the titles of the posts of one certain category
    1. can i change the limit of posts per page in both loops
    2. when in permalink view for the first loop, is there a way to make the second loop still show all the titles of the posts in that category?

    (hi, i’m mister anonymous, i just made myself a user)
    how should multiple loops be used? at the moment i’m just repeating this a couple of times:

    <?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>
    <?php if (in_category(2) && !$single) { ?>
    <?php } else { } ?>
    <?php endforeach; else: ?>
    <?php _e('Sorry, no posts matched your criteria.'); ?>
    <?php endif; ?>

    But now i found something about the get_posts() functions. What is this, how does it work, is there any documentation about it?
    Sorry for the not so obvious questions, but i hope someone knows how it works…


    Problem solved! See here for limiting posts, filtering categories on multiple WP loops:

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Multiple loops for categories’ is closed to new replies.