• Resolved Dandydahlia

    (@dandydahlia)


    Hi there

    I’m a bit of a newbie so I’m sorry if this is such a basic / obvious question 🙂

    My website has standard pages, a blog and also a custom types pages (e.g profiles of people). (It’s currently down as I’m updating it on a localhost so can’t provide a link sorry)

    I would like to use on the site 3 different search boxes visitors can use
    – 1 search box to search the whole site (so it would bring up blog posts, people and also pages)
    – 1 search box to search only the blog
    – 1 search box to search only the people – I have it locked down with Relevanssi so people can’t just enter “Mr” and see every man on the site or “Miss” etc..

    I’ve manage to get the site set up to only search people, but now when I want to get it to search the blog or even the whole site I don’t know how I can tell Relevanssi that it’s a different search? Or if I do this in wordpress a different way?

    The code I use to search the people is:

    <div class="search-text-box">
    <h1>Find a Person</h1>
    <form id="searchform" class="searchform" action="http://mysite.com.au/" method="get" role="search">
    <span>
    <input id="s" type="text" name="s" value="" placeholder="  Search...">
    <input type="button" value="Search">
    </span></form></div>

    I would love any advice pretty please 🙂

    https://wordpress.org/plugins/relevanssi/

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

    (@msaari)

    That search form doesn’t restrict the search at all, it searches the whole site.

    You need to set up Relevanssi to search everything. Then that search box you now have will search for everything.

    To find only people, you need to adjust the search box like this:

    <div class="search-text-box">
    <h1>Find a Person</h1>
    <form id="searchform" class="searchform" action="http://mysite.com.au/" method="get" role="search">
    <span>
    <input type="hidden" name="post_type" value="people" />
    <input id="s" type="text" name="s" value="" placeholder="  Search...">
    <input type="button" value="Search">
    </span></form></div>

    This is assuming your people are in a post type called “people”. Then, assuming your blog posts are posts, this would search only the blog posts:

    <div class="search-text-box">
    <h1>Find a Blog Post</h1>
    <form id="searchform" class="searchform" action="http://mysite.com.au/" method="get" role="search">
    <span>
    <input type="hidden" name="post_type" value="post" />
    <input id="s" type="text" name="s" value="" placeholder="  Search...">
    <input type="button" value="Search">
    </span></form></div>
    Thread Starter Dandydahlia

    (@dandydahlia)

    Awesome. Thanks so much Mikko. You’re a star!

    Thread Starter Dandydahlia

    (@dandydahlia)

    Hi Mikko,

    One more question if that’s alright – when I add
    <input type="hidden" name="post_type" value="people" />

    I’m also seeing blog posts and pages show up in the search results now.
    Is there anything else I need to lock down the search to ONLY search people when I add that input line?

    (Previously I had only People ticked in Relevanssi so only saw people but now to search blogs on the blog pages I unticked it)

    Thank you 🙂

    Thread Starter Dandydahlia

    (@dandydahlia)

    I should also add, in the URL it says:

    localhost/testingsite281015/?post_type=“people”&s=Jack

    So it looks like it’s set to only search “people” post types but it shows all people and also blogs, pages etc.

    Plugin Author Mikko Saari

    (@msaari)

    The URL should look like this:

    localhost/testingsite281015/?post_type=people&s=Jack

    The quotes should definitely not be there. Does that help?

    Thread Starter Dandydahlia

    (@dandydahlia)

    Hi Mikko,

    I removed the quotes from the code:
    <input type=”hidden” name=”post_type” value=”people” />
    to
    <input type=”hidden” name=”post_type” value=people />
    and the URL becomes
    localhost/testingsite281015/?post_type=people&s=Jack
    But it’s a white page and nothing shows.

    I’m not sure how to remove the quotes any other way or why it doesn’t work – can you point me in the right direction on where I’d find the answer?

    Thank you 🙂

    Plugin Author Mikko Saari

    (@msaari)

    That’s really strange – <input type="hidden" name="post_type" value="people" /> is correct, but shouldn’t add any quotes to the URL, I’ve never seen that happen.

    If you type the URL without quotes directly on the URL bar, you just get a white page? Can you access server error logs? There might be a helpful error message.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘3 Search Boxes – one for site, one for blog only, one for custom types page’ is closed to new replies.