Advertisement
Guest User

Grid layout

a guest
Sep 5th, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. <div class="gridcontainer">
  2.  
  3. <!--<h1 class="entry-title"><?php the_title(); ?></h1>-->
  4.  
  5. <?php
  6.  
  7. // Grid Parameters
  8. $counter = 1; // Start the counter
  9. $grids = 3; // Grids per row
  10. $titlelength = 20; // Length of the post titles shown below the thumbnails
  11.  
  12. // The Query
  13. $args=array (
  14. 'post_type' => 'post',
  15. 'posts_per_page' => -1
  16. );
  17. $the_query = new WP_Query($args);
  18.  
  19. // The Loop
  20. while ( $the_query->have_posts() ) :
  21. $the_query->the_post();
  22.  
  23. // Show all columns except the right hand side column
  24. if($counter != $grids) :
  25. ?>
  26.  
  27. <div class="griditemleft">
  28. <div class="postimage">
  29. <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('homepage-thumb'); ?></a>
  30. </div><!-- .postimage -->
  31. <h2 class="postimage-title">
  32. <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
  33. <?php if (mb_strlen($post->post_title) > $titlelength)
  34. { echo mb_substr(the_title($before = '', $after = '', FALSE), 0, $titlelength) . ' ...'; }
  35. else { the_title(); } ?>
  36. </a>
  37. </h2>
  38.  
  39. <div class="postimage-excerpt color1">
  40. <?php the_excerpt(); ?>
  41. <p align='right'><a href="<?php the_permalink() ?>">read more...</a></p>
  42. </div>
  43.  
  44. </div><!-- .griditemleft -->
  45. <?php
  46.  
  47. // Show the right hand side column
  48. elseif($counter == $grids) :
  49. ?>
  50. <div class="griditemright">
  51. <div class="postimage">
  52. <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('homepage-thumb'); ?></a>
  53. </div><!-- .postimage -->
  54. <h2 class="postimage-title">
  55. <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
  56. <?php if (mb_strlen($post->post_title) > $titlelength)
  57. { echo mb_substr(the_title($before = '', $after = '', FALSE), 0, $titlelength) . ' ...'; }
  58. else { the_title(); } ?>
  59. </a>
  60. </h2>
  61.  
  62. <div class="postimage-excerpt">
  63. <?php the_excerpt(); ?>
  64. <p align='right'><a href="<?php the_permalink() ?>">read more...</a></p>
  65. </div>
  66.  
  67.  
  68. </div><!-- .griditemright -->
  69.  
  70. <div class="clear"></div>
  71. <?php
  72. $counter = 0;
  73. endif;
  74. $counter++;
  75. endwhile;
  76. wp_reset_postdata();
  77. ?>
  78.  
  79. </div><!-- .gridcontainer -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement