enter image description here

I am trying to search only post type = products.
However it’s still showing my journal posts that have the searched term.
But even weirder than this, when I search for the word “shoes” the theme can’t seem to find anything. I am using a plugin called “search-everything” to allow my search to extend to some extra post features like tags, (I have tagged the shoes with shoes and even used the word shoes in the product title.
Apart from this the search template is working decently.

Feel free to go to the website I am working on to test it: http://jadepalacecollective.com/?s=shoes

Example above is a search for “mules”.
and it’s also retrieving a post from the journal (the big image on the bottom)

This is my code (I have slimmed it down for readability’s sake)
I first go to this main search.php page

    if (get_post_type() == 'product' ) : ?>

        <header class="page-header">
            <h1 class="page-title searchresults-for"><?php printf( esc_html__( 'Search Results for: %s', 'palace' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
        </header><!-- .page-header -->

        /* Start the Loop */
        while ( have_posts() ) : the_post();
            get_template_part( 'template-parts/content', 'search' );
    else :
        get_template_part( 'template-parts/content', 'none' );
    endif; ?>

If the search.php finds something it then fetches the template search-content.php to display some info about the product.

<?php   if (get_post_type() == 'product' ) : ?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

 <a href="<?php the_permalink(); ?>">
    <?php the_post_thumbnail(); ?>
</article><!-- #post-## -->
<?php endif; ?>

Read more here: Why is my product search displaying journal posts and why is it not working at all with the term "shoes"?


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: