Kareen

Modified Wordpress Loop w/ IF and Else Inside

Apr 12th, 2014
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. <div class="container">
  2.  
  3. <?php if (have_posts()) : ?>
  4.  
  5. <?php
  6. $i = 1;
  7. while (have_posts()) {
  8. the_post();
  9.  
  10. // Add a DIV CONTAINER that holds the FIRST CONDITION
  11. if ($i <= 3) {
  12. the_title();
  13. the_content();
  14. // Add a DIV CONTAINER that holds the FIRST CONDITION
  15.  
  16.  
  17.  
  18. // Add a DIV CONTAINER that holds the SECOND CONDITION
  19. } elseif ($i <= 9) {
  20. the_title();
  21. the_permalink();
  22. // Add a DIV CONTAINER that holds the SECOND CONDITION
  23.  
  24.  
  25. // Add a DIV CONTAINER that holds the THIRD CONDITION
  26. } elseif ($i <= 13) {
  27. the_title();
  28. the_permalink();
  29. // Add a DIV CONTAINER that holds the THIRD CONDITION
  30.  
  31.  
  32. // Add a DIV CONTAINER that holds the FOURTH CONDITION
  33. } elseif ($i <= 15) {
  34. the_title();
  35. // Add a DIV CONTAINER that holds the FOURTH CONDITION
  36.  
  37.  
  38. // Add a DIV CONTAINER that holds the FIFTH CONDITION
  39. } else {
  40. the_title();
  41. // Add a DIV CONTAINER that holds the FIFTH CONDITION
  42. }
  43. $i++;
  44. }
  45.  
  46. ?>
  47.  
  48. <?php else : ?>
  49.  
  50. <h2>No Posts Found</h2>
  51.  
  52. <?php endif; ?>
  53.  
  54. </div>
Advertisement
Add Comment
Please, Sign In to add comment