Advertisement
Naijaping

Grid gallery post type with working pagenation

Oct 5th, 2014
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. /*
  2. Template Name: Photo templates
  3. */
  4. get_header(); ?>
  5.  
  6. <div id="gridcontainer">
  7. <?php
  8.  
  9. $counter = 1; //start counter
  10.  
  11. $grids = 2; //Grids per row
  12.  
  13. $temp = $wp_query;
  14. $wp_query = null;
  15. $wp_query = new WP_Query();
  16. $wp_query->query('showposts=12&post_type=gallery'.'&paged='.$paged);
  17.  
  18. while ($wp_query->have_posts()) : $wp_query->the_post();
  19. ?>
  20.  
  21. <?php
  22. //Show the left hand side column
  23. if($counter == 1) :
  24. ?>
  25. <div class="griditemleft">
  26. <div class="postimage">
  27. <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
  28. <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('archive-gallery-thumb'); ?></a>
  29. </div>
  30. </div>
  31. <?php
  32. //Show the right hand side column
  33. elseif($counter == $grids) :
  34. ?>
  35. <div class="griditemright">
  36. <div class="postimage">
  37. <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
  38. <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('archive-gallery-thumb'); ?></a>
  39. </div>
  40. </div>
  41. <div class="clear"></div>
  42. <?php
  43. $counter = 0;
  44. endif;
  45. ?>
  46. <?php
  47. $counter++;
  48. endwhile;?>
  49. <div class="page-numbers">
  50. <?php wpmy_pagination();?>
  51. </div>
  52. <?php
  53. $wp_query = null;
  54. $wp_query = $temp; // Reset
  55. ?>
  56.  
  57. </div>
  58.  
  59. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement