• Resolved liamslack

    (@liamslack)


    Hi,

    Relevanssi seems to be ignoring my Pages and Products. It builds the index beautifully when only “Pages” and “Products” are selected, but the search returns no results. When I add “Posts” (check the “Posts” box) and reindex, it adds the Posts to the index, and the search will return results – but ONLY results in my Posts.

    Help?

    -Liam

    https://www.ads-software.com/extend/plugins/relevanssi/

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Mikko Saari

    (@msaari)

    What is the value of $wp_query->query_vars[‘post_type’] when you do a search?

    Thread Starter liamslack

    (@liamslack)

    I’m enough of a noob not to know where to find that value. Can you help me out?

    -L

    Thread Starter liamslack

    (@liamslack)

    Hi Mikko –

    I apologize – I only just realized what you were asking. The search returns no results.

    https://walkeraudio.com/?s=%24wp_query-%3Equery_vars%5B%27post_type%27%5D&post_type=post

    Thoughts?

    -Liam

    Plugin Author Mikko Saari

    (@msaari)

    No, that’s not what I was asking…

    Put this on your search results template and then do a search:

    var_dump($wp_query->query_vars['post_type']);

    Thread Starter liamslack

    (@liamslack)

    I pasted the above into my searchform.php file in the root of my theme. I didn’t know where to paste it, so I just did so at the end of the existing code.

    After doing so, the above: var_dump($wp_query->query_vars[‘post_type’]); now appears under the error message “Not Found” on my results page.

    Any thoughts?

    Plugin Author Mikko Saari

    (@msaari)

    Change it to this:

    <?php var_dump($wp_query->query_vars['post_type']); ?>

    Thread Starter liamslack

    (@liamslack)

    It now reads “NULL” under the error.

    -Liam

    Plugin Author Mikko Saari

    (@msaari)

    Hmm… Anyway, I think the problem is that something in your site restricts the search to posts only. That causes the search to fail when no posts are in the index. It’s probably your theme, somehow. If you can copy your search results template to a pastebin and show it to me, I can take a look at it.

    Thread Starter liamslack

    (@liamslack)

    <form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
        <div><label class="screen-reader-text" for="s"><?php echo apply_filters( 'yiw_searchform_label', __( 'Search for:', 'yiw' ) ) ?></label>
            <input type="text" value="<?php the_search_query(); ?>" name="s" id="s" />
            <input type="submit" id="searchsubmit" value="<?php echo apply_filters( 'yiw_searchform_submit_label', __( 'Search', 'yiw' ) ) ?>" />
            <input type="hidden" name="post_type" value="<?php echo apply_filters( 'yiw_searchform_post_type', 'post' ) ?>" />
        </div>
    </form>

    Is this what you needed?

    -Liam

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum’s parser.]

    Plugin Author Mikko Saari

    (@msaari)

    I asked for search results template, not search form, but actually, here’s the key:

    <input type="hidden" name="post_type" value="<?php echo apply_filters( 'yiw_searchform_post_type', 'post' ) ?>" />

    This line here restricts the search to posts only. Remove it, and everything should be fine.

    Thread Starter liamslack

    (@liamslack)

    Beautiful. Thanks so much for your patience and help, Mikko!

    -Liam

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Plugin: Relevanssi – A Better Search] Pages & Products = No Results’ is closed to new replies.