WordPress.org

Ready to get started?Download WordPress

Forums

Relevanssi - A Better Search
[resolved] Pages & Products = No Results (12 posts)

  1. liamslack
    Member
    Posted 1 year ago #

    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

    http://wordpress.org/extend/plugins/relevanssi/

  2. Mikko Saari
    Member
    Plugin Author

    Posted 1 year ago #

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

  3. liamslack
    Member
    Posted 1 year ago #

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

    -L

  4. liamslack
    Member
    Posted 1 year ago #

    Hi Mikko -

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

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

    Thoughts?

    -Liam

  5. Mikko Saari
    Member
    Plugin Author

    Posted 1 year ago #

    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']);

  6. liamslack
    Member
    Posted 1 year ago #

    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?

  7. Mikko Saari
    Member
    Plugin Author

    Posted 1 year ago #

    Change it to this:

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

  8. liamslack
    Member
    Posted 1 year ago #

    It now reads "NULL" under the error.

    -Liam

  9. Mikko Saari
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  10. liamslack
    Member
    Posted 1 year ago #

    <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.]

  11. Mikko Saari
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  12. liamslack
    Member
    Posted 1 year ago #

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

    -Liam

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic