Advertisement
trigger008

Search LD

Sep 27th, 2019
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.24 KB | None | 0 0
  1. <?php
  2. get_header();
  3. global $ae_post_factory, $post, $wp_query;
  4.  
  5. // default args
  6. $args = array(
  7. 'post_type' => 'place',
  8. 'paged' => get_query_var( 'paged' ) ,
  9. //'meta_key' => 'rating_score',
  10. 'post_status' => array('publish'),
  11. 's' => $_REQUEST['s'],
  12. 'radius' => 10
  13. );
  14.  
  15. if(isset($_REQUEST['l']) && $_REQUEST['l'] != '') {
  16. $args['location']= $_REQUEST['l'];
  17. $args['tax_query'] = array(
  18. array(
  19. 'taxonomy'=>'location',
  20. 'field'=> 'slug',
  21. 'terms'=> $_REQUEST['l']
  22. )
  23. );
  24. }
  25. if(isset($_REQUEST['c']) && $_REQUEST['c'] != '') {
  26. $args['place_category'] = $_REQUEST['c'];
  27. }
  28. /**
  29. * generate nearby center
  30. */
  31. if(isset($_REQUEST['center']) && $_REQUEST['center'] != '') {
  32. $center = explode(',', $_REQUEST['center']);
  33. $args['near_lat'] = $center[0];
  34. $args['near_lng'] = $center[1];
  35. unset($_REQUEST['center']);
  36. $args['radius'] = $_REQUEST['radius'] ;
  37. }
  38. // nearby radius
  39.  
  40. if(isset($_REQUEST['days']) && $_REQUEST['days']) {
  41. $args['date_query'] = array(
  42. array(
  43. 'column' => 'post_date_gmt',
  44. 'after' => ($_REQUEST['days'] > 1) ? $_REQUEST['days'].' days ago ' : '1 day ago ',
  45. )
  46. );
  47. }
  48.  
  49. $place_obj = $ae_post_factory->get('place');
  50. $wp_query = new WP_Query($args);
  51.  
  52. $found_posts = '<span class="found_post">'.$wp_query->found_posts.'</span>';
  53. $plural = sprintf(__('%s places ',ET_DOMAIN), $found_posts);
  54. $singular = sprintf(__('%s place',ET_DOMAIN),$found_posts);
  55. $convert = false;
  56. ?>
  57. <div>
  58. <!-- Bar Post Place -->
  59. <section id="bar-post-place-wrapper">
  60. <div class="container">
  61. <div class="row">
  62. <div class="col-md-9 col-xs-8">
  63. <h2 class="top-title-post-place">
  64. <?php
  65. printf( __( 'Search Results for "%s": ', ET_DOMAIN ), get_search_query() );
  66. ?>
  67. <span class="found_search plural <?php if( $found_posts > 1 ) { echo 'hide'; } ?>" >
  68. <?php echo $plural; ?>
  69. </span>
  70. <span class="found_search singular <?php if( $found_posts <= 1 ) { echo 'hide'; } ?>">
  71. <?php echo $singular; ?>
  72. </span>
  73. </h2>
  74. </div>
  75. </div>
  76. </div>
  77. </section>
  78. <!-- Bar Post Place / End -->
  79. <!-- List Place -->
  80. <section id="list-places-wrapper">
  81. <div class="container">
  82. <!-- place list with sidebar -->
  83. <div class="row">
  84. <div class="col-md-9 publish_place_wrapper" id="publish_place_wrapper">
  85. <div class="filter-wrapper">
  86. <?php get_template_part( 'template/place', 'filter' ); ?>
  87. </div>
  88.  
  89. <div class="clearfix"></div>
  90. <div class="row">
  91. <?php if(have_posts()) { ?>
  92. <ul class="list-places list-posts" id="publish-places" data-list="publish" data-thumb="medium_post_thumbnail">
  93. <?php
  94. $post_arr = array();
  95. while (have_posts()) {
  96.  
  97. the_post();
  98. global $post, $ae_post_factory;
  99. $ae_post = $ae_post_factory->get('place');
  100. $convert = $ae_post->convert($post, 'medium_post_thumbnail');
  101. $post_arr[] = $convert;
  102. get_template_part( 'template/loop' , 'place' );
  103. }
  104.  
  105. echo '<script type="json/data" class="postdata" id="ae-publish-posts"> ' . json_encode($post_arr) . '</script>';
  106.  
  107. ?>
  108.  
  109. </ul>
  110. <div class="paginations-wrapper main-pagination" >
  111. <?php
  112. ae_pagination($wp_query);
  113. wp_reset_postdata();
  114. ?>
  115. </div>
  116. <?php
  117. }else {
  118. get_template_part('template/place', 'notfound' );
  119. }
  120. ?>
  121. </div>
  122. </div>
  123. <?php
  124. get_sidebar();
  125. ?>
  126. </div>
  127. </div>
  128. </section>
  129. </div>
  130. <!-- List Place / End -->
  131.  
  132. <?php if($convert) { ?>
  133. <!--<script type="json/data" id="place_id"><?php echo json_encode(array('id' => $convert->ID, 'ID' => $convert->ID)); ?></script> -->
  134. <script type="json/data" id="place_id"><?php echo json_encode($convert); ?></script>
  135. <?php } ?>
  136. <?php if(isset($args['near_lng'] )) { ?>
  137. <script type="json/data" id="nearby_location"><?php echo json_encode(array('latitude' => $args['near_lat'], 'longitude' => $args['near_lng'] )); ?></script>
  138. <?php } ?>
  139.  
  140. <!-- List Place / End -->
  141.  
  142.  
  143. <?php
  144. get_footer();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement