Posted By

izuddinhelmi on 12/14/10


Tagged

test


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

qubestream


wp if else


 / Published in: PHP
 

If Else loop

  1. <?php
  2. $count = 0;
  3. query_posts('showposts=5');
  4. if (have_posts()) : while (have_posts()) : the_post();
  5. $count++;
  6. ?>
  7.  
  8. <?php if ($count == 1) : ?>
  9. <ul id="featured-main">
  10. <h3 class="sec-header"><span><?php the_time('F d, Y'); ?></span></h3>
  11. <li>
  12. <h2 class="entry-title"><a href="<?php the_permalink() ?>" title="Permalink to <?php the_title_attribute() ?>" rel="bookmark"><?php the_title() ?></a></h2>
  13. <div class="author">By <?php the_author_posts_link(); ?></div>
  14. <div class="thumbnail"><a href="<?php the_permalink() ?>" title="Permalink to <?php the_title_attribute() ?>" rel="bookmark"><?php the_post_thumbnail('big-post-thumbnail'); ?></a></div>
  15.  
  16. <div class="meta">
  17. <span class="date"> <?php the_time('F d, Y'); ?></span>
  18. <span class="categories"><?php the_category(', ') ?></span>
  19. <span class="comments"><?php comments_popup_link('0 Comment', '1 Comment',
  20. '% Comments', 'comments-link'); ?></span>
  21. </div>
  22. <?php the_excerpt(); ?>
  23. </li>
  24. </ul><!--featured-main-->
  25.  
  26. <?php else : ?>
  27.  
  28. <div id="featured-news"><!--still in grid_6-->
  29. <ul>
  30. <li>
  31. <h2><a href="<?php the_permalink() ?>" title="Permalink to <?php the_title_attribute() ?>" rel="bookmark"><?php the_title() ?></a></h2>
  32. <div class="meta">
  33. <span class="date"> <?php the_time('F d, Y'); ?></span>
  34. <span class="categories"><?php the_category(', ') ?></span>
  35. <span class="comments"><?php comments_popup_link('0 Comment', '1 Comment',
  36. '% Comments', 'comments-link'); ?></span>
  37. </div>
  38. <?php if(has_post_thumbnail()) { ?>
  39. <div class="thumbnail"><a href="<?php the_permalink() ?>" title="Permalink to <?php the_title_attribute() ?>" rel="bookmark"><?php the_post_thumbnail(); ?></a></div>
  40. <?php } ?>
  41. <?php the_excerpt(); ?>
  42.  
  43. </li>
  44. </ul>
  45. </div><!--featured-news-->
  46.  
  47. <?php endif; ?>
  48. <?php endwhile; wp_reset_query(); ?>
  49. <?php endif; ?>

Report this snippet  

You need to login to post a comment.