WordPress.org

Ready to get started?Download WordPress

Forums

Multiple loops for categories (7 posts)

  1. Anonymous
    Unregistered
    Posted 10 years ago #

    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?

  2. dss
    Member
    Posted 10 years ago #

    isn't it:
    $cat="x"
    ?
    dss

  3. carthik
    Member
    Posted 10 years ago #

    $cat = '1' should identify that you want to use the category with ID=1
    http://photomatt.net/archives/2004/05/19/asides/
    the above link also shows an example of how to use in_category().
    Hope that helps.

  4. Anonymous
    Unregistered
    Posted 10 years ago #

    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
    problems:
    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?

  5. cartel82
    Member
    Posted 10 years ago #

    (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...

  6. Zaaba
    Member
    Posted 10 years ago #

    bump!

  7. Zaaba
    Member
    Posted 10 years ago #

    Problem solved! See here for limiting posts, filtering categories on multiple WP loops:
    http://wordpress.org/support/index.php?action=vthread&forum=10&topic=6012&page=0

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.