Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

1 Loop Different OutPuts WordPress

  • SOLVED

A Similar Question Has Been Asked About this

<?php $i = 1; ?>

<?php $my_query = new WP_Query('showposts=10');

while ($my_query->have_posts()) : $my_query->the_post(); ?>

<?php if ( $i == 1 ) { ?>

//Big thumb and other staff goes here

<?php } elseif ( $i > 1 ) { ?>

//Other posts go here

<?php } ?>

<?php $i=$i+1; ?>

<?php endwhile; ?>


What I Want is :

<ul>

First Loop - Show the Latest 9 Posts

</ul>

<div id="****">

2nd Loop Show the Rest of the Posts, Which Will be Around 9

</div>

Answers (3)

2011-02-17

Honzik A. answers:

Do you want:

<ul>

post 1
post 2
.....
post 9

</ul>

<div id="****">

post 10
post 11
.....
</div>

?


Honzik A. comments:

Marvin you can tray whit this code:

<?php
query_posts('showposts=9');
$ids = array(); while (have_posts()) : the_post();
$ids[] = get_the_ID(); ?>
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<?php endwhile; ?>

<h3>Older posts</h3>
<div class="older_posts">
<?php query_posts(array('post__not_in' => $ids));
while (have_posts()) : the_post();?>
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<?php endwhile; ?>
</div>

2011-02-17

Sébastien | French WordpressDesigner answers:


<?php $my_query = new WP_Query('showposts=9');
if ($my_query->have_posts()) : ?>
<ul>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
<?php endif ; ?>

<?php $my_query2 = new WP_Query('offset=9');
if ($my_query2->have_posts()) : ?>
<div>
<?php while ($my_query2->have_posts()) : $my_query2->the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</div>
<?php endif ; ?>


Sébastien | French WordpressDesigner comments:

the first loop display post1, post2, post3... post9

the second loop displays the others : post10, post11 ...


Sébastien | French WordpressDesigner comments:

Marvin, that's OK ?

2011-02-17

enodekciw answers:

<?php $i = 1; ?>

<?php $my_query = new WP_Query('showposts=18');

while ($my_query->have_posts()) : $my_query->the_post(); ?>

<?php if ( $i <= 9 ) { ?>

//Big thumb and other staff goes here

<?php } elseif ( $i > 9 ) { ?>

//Other posts go here

<?php } ?>

<?php $i=$i+1; ?>

<?php endwhile; ?>