开发者

Create Multiple Loop Page

开发者 https://www.devze.com 2023-04-13 08:16 出处:网络
hi i want to create a multiple loop page for archive / category / tag i am very confused, plz help <?php

hi i want to create a multiple loop page for archive / category / tag

i am very confused, plz help

<?php 
$count = 1;
if (have_posts()) : while (have_posts()) : the_post();          
if($count == 1) : ?>

<-- First loop --> I need only 1 post in this loop (so i add above code)

 <?php else : ?>
 <?php the_post_thumbnail(); ?>
 <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
 <?php echo limit_words(get_the_excerpt(), '44'); ?>

<-- second loop --> (1 post in this loop)

 <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
 <?php echo limit_words(get_the_excerpt(), '35'); ?>

<-- Third loop --> (4 post in this loop)

  <ul><li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
  </li></ul>

<-- Fourth loop --> (Rest of all posts will be in this loop)

 <?php the_post_thumbnail('thumbnail', array('class' => 'cover')); ?>
 <div class=""></div><a href="<?php the_permalink() ?&g开发者_如何学Got;"><?php the_title(); ?></a>
 <?php echo limit_words(get_the_excerpt(), '44'); ?></div>

 <?php endif; ?>    
 <?php $count++; ?> 
 <?php endwhile; ?> 
 </div><!-- /.post -->
 <?php else : ?>

 <h2 class="archiveTitle"><?php _e('Sorry, nothing matched your criteria','linepress');?></h2> 
 <?php endif; ?>


Check out http://codex.wordpress.org/The_Loop that has a section on using multiple loops. that has always worked for me.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号