Support » Plugin: Relevanssi - A Better Search » [Plugin: Relevanssi – A Better Search] 2 diferent searchs with 2 diferent filters

  • Hi friends,

    I have a simple issue… I need 2 search boxs in diferent parts of my web:

    – At the first one I need to exclude an especific custom post type
    – At the other I want to search at just this custom post type excluded before…

    I had solved it without the Relevanssi plugin. I assigned the argument exclude_from_search to true for this especific custom post type, so the default search exclude it.

    Then, I created the second search and put the code <input type="hidden" name="post_type" value="that_custom_post_type" /> and it works well.

    But I want to use the Relevanssi´s features, but I couldn´t solve this problem.

    Any help??
    Thanks!

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

Viewing 15 replies - 1 through 15 (of 18 total)
  • +1: I would love the same thing 🙂

    I’m looking for the exact same thing!

    Plugin Author Mikko Saari

    (@msaari)

    Well, this almost works with Relevanssi. The problem is with the exclusion, because if you set exclude_from_search and indexing to “all public types”, you can’t later include.

    So, this’ll take some fixing. However, I have a fairly simple solution: support for negative post types.

    You could then do this in the first search:

    <input type="hidden" name="post_type" value="-foo" />

    and this in the second search:

    <input type="hidden" name="post_type" value="foo" />

    And it would work the way you want.

    I’m going to work on Relevanssi a bit today and tomorrow, probably resulting in a new version in couple of days, and I’ll include this.

    Plugin Author Mikko Saari

    (@msaari)

    Looks like WordPress won’t let me do that. I’ll have to come up with another solution.

    Plugin Author Mikko Saari

    (@msaari)

    I decided to take the easy way out: just replicate WordPress behaviour. What you tried will work with Relevanssi starting from the next version (2.6, probably).

    Plugin Author Mikko Saari

    (@msaari)

    Just committed version 2.6, so once that’s available, try to see if your original method works.

    Thank you msaari!

    Ééé!! Thanks msaari! 🙂

    msaari, this works perfectly! Thank you so much!

    To anyone else, reading the thread later, just to save you some time, here’s how I got it working…

    In the WordPress Admin, go to Settings >> Relevanssi, and under “Restrict search to these categories and tags:” I entered the category numbers for all the categories I wanted the main search to index.

    Then I edited my theme, and added a second search field, with a unique “name” and “id” and added this line of code within the form…
    <input type='hidden' name='cat' value='14' />

    So now the main search field searches every category, except for 14, and the second search field only searches category 14 – which is exactly what I was looking for!

    Once again, thank you msaari. It’s very cool to express a desire for a certain feature, and then have a solution in less than a day! You rock!

    Plugin Author Mikko Saari

    (@msaari)

    I’m glad I could help you.

    @masaari, I thought it was ok, but I´m afraid it´s not…

    1) I need to restrict the general search to don´t find anything in a especific post type. So, I put the exclude_from_search at this post type arguments…

    2) At the Relevanssi Admin I choose to index ‘All public post types’ so it excludes my especific post type. Now, the general search is all right.

    3) I want my second search to find posts just in that especific post type, so I add the code <input type="hidden" name="post_type" value="that_custom_post_type" />

    But it doesn´t find anything. I think the ‘All public post types’ is limiting this search too…

    I´m using the version 2.6.

    Plugin Author Mikko Saari

    (@msaari)

    Yes, change “All public post types” to “Everything”. That way everything will be indexed, and the exclude from search should restrict the general search as you wish.

    @msaari If I define it to “Everything” the general search can find my “exclude_from_search” post type…

    Plugin Author Mikko Saari

    (@msaari)

    Index everything and check the “Respect exclude_from_search for custom post types:” checkbox.

    Now is perfect! I didn´t see this checkbox before.
    Thanks again @msaari

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘[Plugin: Relevanssi – A Better Search] 2 diferent searchs with 2 diferent filters’ is closed to new replies.