Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. $wp_query = new WP_Query( array(
  2. 'ep_integrate' => true,
  3. 'post_type' => 'post',
  4. 'posts_per_page' => 20,
  5. 'tax_query' => array(
  6. array(
  7. 'taxonomy' => 'category',
  8. 'terms' => array( get_query_var('cat') ),
  9. 'field' => 'term_id',
  10. ),
  11. ),
  12. ) );
  13.  
  14.  
  15. if ( $wp_query->have_posts() ) {
  16.  
  17. // Start the loop.
  18. while ( $wp_query->have_posts() ) : $wp_query->the_post();
  19.  
  20. /**
  21. * Run the loop for the search to output the results.
  22. * If you want to overload this in a child theme then include a file
  23. * called content-search.php and that will be used instead.
  24. */
  25. get_template_part('template-parts/content', 'search');
  26.  
  27. // End the loop.
  28. endwhile;
  29.  
  30. // Previous/next page navigation.
  31. the_posts_pagination(array(
  32. 'prev_text' => __('Previous page', 'twentysixteen'),
  33. 'next_text' => __('Next page', 'twentysixteen'),
  34. 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __('Page', 'twentysixteen') . ' </span>',
  35. ));
  36.  
  37. wp_reset_postdata();
  38.  
  39. // If no content, include the "No posts found" template.
  40. } else {
  41.  
  42. get_template_part('template-parts/content', 'none');
  43. }
  44.  
  45. function elasticpress_search( $wp_query ) {
  46. if ( is_search() ) {
  47. $query->set( 'ep_integrate', true ); }
  48. }
  49.  
  50. add_action( 'pre_get_posts', 'elasticpress_search' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement