Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $wp_query = new WP_Query( array(
- 'ep_integrate' => true,
- 'post_type' => 'post',
- 'posts_per_page' => 20,
- 'tax_query' => array(
- array(
- 'taxonomy' => 'category',
- 'terms' => array( get_query_var('cat') ),
- 'field' => 'term_id',
- ),
- ),
- ) );
- if ( $wp_query->have_posts() ) {
- // Start the loop.
- while ( $wp_query->have_posts() ) : $wp_query->the_post();
- /**
- * Run the loop for the search to output the results.
- * If you want to overload this in a child theme then include a file
- * called content-search.php and that will be used instead.
- */
- get_template_part('template-parts/content', 'search');
- // End the loop.
- endwhile;
- // Previous/next page navigation.
- the_posts_pagination(array(
- 'prev_text' => __('Previous page', 'twentysixteen'),
- 'next_text' => __('Next page', 'twentysixteen'),
- 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __('Page', 'twentysixteen') . ' </span>',
- ));
- wp_reset_postdata();
- // If no content, include the "No posts found" template.
- } else {
- get_template_part('template-parts/content', 'none');
- }
- function elasticpress_search( $wp_query ) {
- if ( is_search() ) {
- $query->set( 'ep_integrate', true ); }
- }
- add_action( 'pre_get_posts', 'elasticpress_search' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement