ElasticPress – post content not displayed after custom search


I have issue with ElasticPress.

After successful installation and connection of WordPress and ElasticPress and indexing few hundred posts for testing, i found everything in order until I tried to create custom WP_Query. The result page had only title lines but the post content was not displayed. In the search.php I wrote this

$wp_query = new WP_Query( array(
                    'ep_integrate'   => true,
                    'post_type'      => 'post',
                    'posts_per_page' => 20,
                    'tax_query' => 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.

                    // Previous/next page navigation.
                        'prev_text' => __('Previous page', 'twentysixteen'),
                        'next_text' => __('Next page', 'twentysixteen'),
                        'before_page_number' => '<span class="meta-nav screen-reader-text">' . __('Page', 'twentysixteen') . ' </span>',


                    // If no content, include the "No posts found" template.
                } else {

                    get_template_part('template-parts/content', 'none');

Unfortunately I didn’t find anything about how to correctly use ElasticPress when building custom queries. All tutorials are simple, shows how to write new WP_Query and the results are built without any other programming.

The global post var is not empty, still the post content missing on page. WordPress is 4.6.1, ElasticPress is 2.1.2.

Can someone direct me to the correct way of creating custom queries and display the results. I know ES but I’m almost beginner in WP.

, fly 7 years 2017-01-19T06:22:42-05:00 0 Answers 69 views 0

Leave an answer