0

On one particular site, when I do a search, not all relevant results are returned.

Example:

Post Title: This is xxx

Post Content: Hello World, this is xxx.

When searching for 'xxx', the post isn't returned in the search results.

Is this expected behaviour, and how do I fix this?

This is the code for the search template:

<?php get_header();  ?>

<div class="vw-page-wrapper clearfix">
    <div class="container">
        <div class="row">
            <div class="vw-page-content col-md-8" role="main">

                <?php do_action( 'vw_action_before_archive_posts' ); ?>
                <?php get_template_part( 'templates/post-box/post-layout-'.vw_get_archive_blog_layout() ); ?>
                <?php do_action( 'vw_action_after_archive_posts' ); ?>

            </div>
        </div>
    </div>
</div>

<?php get_footer(); ?>
0

Doesn't look like this is the fault of the template. There could be another plugin trying to filter things. Also please try https://wordpress.org/plugins/relevanssi/

0

I don't know what the problem exactly was, but I solved it by writing a custom search query:

<?php $args = array(
    's' => $_GET['s'],
    'post_type' => array( 'post', 'page'),
    'post_status' => 'publish',
    'posts_per_page' => -1
);
$custom_search = new WP_Query( $args );
if ( $custom_search->have_posts() ) {

    while ( $custom_search->have_posts() ) : $custom_search->the_post(); ?>
        <div class="block-grid-item">
            <div class="entry-content clearfix pagecategory">
                <h2 class="newstitle"><a href="<?php the_permalink();?>"><?php the_title(); ?></a></h2>
                <?php the_excerpt(); ?>
            </div>
        </div>
    <?php endwhile;

} else { ?>
    <h2>Your search didn't return any results.</h2>
<?php } ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.