Advertisement
Guest User

Numbered Pagination

a guest
Apr 7th, 2016
637
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.37 KB | None | 0 0
  1. <?php
  2. /**
  3. * Template Name: Search Page Template
  4. * @link https://codex.wordpress.org/Template_Hierarchy
  5. * @package essential
  6. */
  7.  
  8. get_header(); ?>
  9. <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
  10. <?php
  11. if( isset( $_GET['location'] ) && isset( $_GET['service'] ) ){
  12. $location = $_GET['location'];
  13. $service = $_GET['service'];
  14. $listing_args = array(
  15. 'post_type' => 'business',
  16. 'posts_per_page' => 10,
  17. 'meta_key' => 'listing_num',
  18. 'orderby' => 'meta_value_num',
  19. 'order' => 'DESC',
  20. 'offset' => ($paged -1) * 10,
  21. 'tax_query' => array(
  22. 'relation' => 'AND',
  23. array(
  24. 'taxonomy' => 'location',
  25. 'field' => 'name',
  26. 'terms' => $location,
  27. ),
  28. array(
  29. 'taxonomy' => 'service',
  30. 'field' => 'name',
  31. 'terms' => $service,
  32. )
  33. ),
  34. );
  35. }
  36. ?>
  37. <div class="row" id="content">
  38. <div class="medium-3 columns" id="search-sidebar">
  39. <?php get_sidebar(); ?>
  40. </div>
  41. <div class="medium-9 columns" id="search-content">
  42. <h1><?php the_title(); ?></h1>
  43. <?php $listing_query = new WP_Query( $listing_args ); ?>
  44. <?php if($listing_query->have_posts() ): ?>
  45. <?php while( $listing_query->have_posts() ): $listing_query->the_post(); ?>
  46. <?php if( get_field('business_paid') ): ?>
  47. <div class="paying-listing columns">
  48. <div class="premium-business">
  49. <div class="large-6 columns">
  50. <?php the_post_thumbnail(); ?>
  51. </div>
  52. <div class="premium-single-listing row">
  53. <div class="large-6 columns premium-listing-content">
  54. <h3><?php the_title(); ?></h3>
  55. <?php if( get_field('phone_number') ): ?>
  56. <p><i class="fa fa-phone"></i> <?php the_field('phone_number'); ?></p>
  57. <?php endif; ?>
  58. <?php if( get_field('mobile') ): ?>
  59. <p><i class="fa fa-mobile"></i> <?php the_field('mobile_number'); ?></p>
  60. <?php endif; ?>
  61. <?php if( get_field('email') ): ?>
  62. <p><i class="fa fa-envelope-o"></i> <?php the_field('email'); ?></p>
  63. <?php endif; ?>
  64. <?php if( get_field('website') ): ?>
  65. <p><i class="fa fa-desktop"></i> <?php the_field('website'); ?></p>
  66. <?php endif; ?>
  67. <?php if( get_field('address') ): ?>
  68. <p><i class="fa fa-home"></i> <?php the_field('address'); ?></p>
  69. <?php endif; ?>
  70. <a href="<?php the_permalink(); ?>">Read More</a>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. <?php else: ?>
  76. <div class="non-paying-listing">
  77. <h3><?php the_title(); ?></h3>
  78. <?php if( get_field('phone_number') ): ?>
  79. <p><i class="fa fa-phone"></i> <?php the_field('phone_number'); ?></p>
  80. <?php endif; ?>
  81. <?php if( get_field('mobile') ): ?>
  82. <p><i class="fa fa-mobile"></i> <?php the_field('mobile_number'); ?></p>
  83. <?php endif; ?>
  84. <?php if( get_field('email') ): ?>
  85. <p><i class="fa fa-envelope-o"></i> <?php the_field('email'); ?></p>
  86. <?php endif; ?>
  87. <?php if( get_field('website') ): ?>
  88. <p><i class="fa fa-desktop"></i> <?php the_field('website'); ?></p>
  89. <?php endif; ?>
  90. <?php if( get_field('address') ): ?>
  91. <p><i class="fa fa-home"></i> <?php the_field('address'); ?></p>
  92. <?php endif; ?>
  93. </div>
  94. <?php endif; ?>
  95. <?php endwhile; ?>
  96. <?php wp_reset_postdata(); ?>
  97. <a href="<?php echo get_pagenum_link(2); ?>">Page 2</a>
  98. <?php else: ?>
  99. <p>No businesses found, please try again</p>
  100. <?php endif; ?>
  101. <?php wp_reset_query(); ?>
  102. </div>
  103. </div>
  104. <?php
  105. get_footer();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement