• Okay, so I was trying to add special criteria for searches. The rough idea is I’ve got this in my search.php:

    parse_str($_SERVER["QUERY_STRING"], $query_arr);
    //add and change some of the elements of $query_arr
    query_posts($query_arr); ?>

    But I would also like to order by relevance, so I tried out Relevanssi. And maybe it’s incompatible with the custom modified search, because it isn’t changing the order at all.

    And query_posts does have an orderby parameter, but none of the listed values are what I want.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter drcherrychocolate

    (@drcherrychocolate)

    Okay, found I could get it to work by using
    relevanssi_query()
    where I would normally use query_posts()

    Thread Starter drcherrychocolate

    (@drcherrychocolate)

    I’m still having problems with this. The relevanssi_query() parameter isn’t what I thought it was. I thought I could just pass it $query_arr, but I guess that’s not it, so it’s ignoring all the search parameters I set.

    How do I do a relevanssi search with criteria that I’ve set? I’ve got stuff like:

    $query_arr['year']=$date_arr[0];
    $query_arr['monthnum']=$date_arr[1];
    $query_arr['category__not_in']=Array('13','30');
    $query_arr['post_type']='posts';
    if ($query_arr['location']!='') {
     if ($query_arr['cat']!='') {
      $query_arr['category__and']=array($query_arr['cat'],$query_arr['location']);
      $query_arr['cat']=null;
      $query_arr['location']=null;
     } else {
      $query_arr['cat']=$query_arr['location'];
     }
    }

    And I could get it to work with the regular search by just calling
    query_posts($query_arr)
    but I don’t know how to use any of this stuff with relevanssi

    Relevanssi doesn’t recognise any of that, because you generally can’t do that with search form parameters. From the search form, WordPress passes only few parameters to the search engine (for example cat and custom post type). Thus, Relevanssi doesn’t know how to handle any of the stuff you want to do.

    It can support that kind of filters with aome hacking, but I’m not sure it’s worth the trouble for general release.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Search relevance after adding special search criteria’ is closed to new replies.