WordPress.org

Ready to get started?Download WordPress

Forums

multiple loops (2 posts)

  1. Lum
    Member
    Posted 7 years ago #

    Hi, I want to have 2 loops on my index page. The first one has to show 4 post form a certain category, and the second one 10 post from another category.
    I've tried with query_post and $my_query, but they don't seems to work. This is how my code looks like:

    <?php query_posts('category_name=appuntamenti&showpost=4'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class="headlines">
    <?php the_time('d/m/Y') ?>
    &nbsp;<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    <?php the_title(); ?>
    </a></div>
    </div>
    <?php endwhile;?>
    <!-- loop 2-->
    <div class="loop"><img src="http://demon.wererabbit.net/wp-content/themes/demon/images/notiziepubbliche.gif"></div>
    <?php query_posts('category_name=notizie&showpost=10'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    <?php the_title(); ?>
    </a></h1>
    <?php the_time('F jS, Y') ?>
    <!-- by <?php the_author() ?> -->
    <div class="entrytext">
    <?php the_excerpt('Read the rest of this entry &raquo;'); ?>
    </div>
    </div>
    <?php endwhile; ?>

  2. Samuel B
    moderator
    Posted 7 years ago #

    Have a read here:
    http://codex.wordpress.org/The_Loop#Multiple_Loops
    There are examples of multiple loops and excluding categories.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags