[Plugin: Relevanssi – A Better Search] Relevanssi results don't show up
-
Hi! Following a short blurb on your facebook page:
“Hiya! Bug? When I have Relevanssi activated, the SQL request is rather short, and ends with 1=2. If I deactivate Relevanssi, the request stays the same, and results actually get displayed. There is no query_posts() call on my search.php. Help?
—–
That is correct – Relevanssi shuts down the default WP search like that, so it doesn’t run on the background. However, it should replace the search results with better results. There’s something else on your theme that is disabling Relevanssi somehow. Please post on the WordPress.org support forums and show me your search.php so I can take a look at it.”Here’s the code
get_header(); // We need to define our query so that it when using the pagination the correct results appear. $search = new WP_Query( array( 'post_type' => $_GET['post_type'] ? $_GET['post_type'] : 'page', 's' => get_query_var( 's' ), 'paged' => get_query_var( 'page' ) ? get_query_var( 'page' ) : 1 ) ); $info = es_get_query_info(); ?> <div class="col-12"> <div class="page-content"> <div class="clearfix"> <div class="title-details left"> <p class="h2 mb-0"><em>Showing <strong><?php echo $info['showing_start']; ?></strong>-<strong><?php echo $info['showing_end']; ?></strong> of <?php echo $info['post_count']; ?> results for</em></p> <h1>“<span class="color-cc2127"><?php echo $info['searched']; ?></span>”</h1> </div> <div class="page-search right"> <?php get_search_form(); ?> <p class="mb-0"><em>Please <a href="#">sign in</a> to search the dictionary</em></p> </div> </div> <?php // Add in the navigation to the top. es_pagination_navigation( 'post-pagination top' ); // Set up the incrementing var based on what page of results we are on. $i = ( $info['showing_start'] - 1 ); if( $search->have_posts() ) : while( $search->have_posts() ) : $search->the_post(); $i += 1; get_template_part( 'loop', 'results' ); endwhile; endif; // Add in the navigation to the bottom. es_pagination_navigation( 'post-pagination bottom' ); // Reset the WordPress query. wp_reset_query(); unset( $info, $i ); ?> </div> </div> <?php get_footer();
And the loop file:
global $info, $i; // es_preit( $info ); ?> <article <?php post_class( 'clearfix search' ); ?>> <div class="item left"> <?php echo $i . '.'; ?> </div> <div class="entry right"> <h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php echo es_search_wrapper( array( 'wrapper' => 'span', 'class' => 'highlight', 'term' => $info['searched'], 'string' => get_the_title( $post->ID ) ) ); ?></a></h2> <p><?php echo es_search_wrapper( array( 'wrapper' => 'strong', 'class' => 'highlight', 'term' => $info['searched'], 'string' => get_the_excerpt( $post->ID ) ) ); ?></p> </div> </article>
- The topic ‘[Plugin: Relevanssi – A Better Search] Relevanssi results don't show up’ is closed to new replies.