Search - Doesn't search custom fields.

madturnip

New Member
I am not sure if it just me, but the built in search does not search custom fields. I have added a customer field with drop down selection. When I type the word North America, since the custom drop down was location, it returns nothing.

Is this what was intended or something I am doing wrong?
 

Basti

Administrator
Staff member
Search has not been combined with custom join elements, as that feature was just released last version. But thank you pointing that out, we will add it to the list :)
 

daannet

Member
Of course you can add databese fields in your /sources/search.php

You see something like this:
PHP:
    $query = "SELECT sites.username, url, title, description, banner_url, category, acf_keywords FROM {$CONF['sql_prefix']}_sites sites, {$CONF['sql_prefix']}_stats stats WHERE active = 1 AND sites.username = stats.username AND (";
    $i = 0;
    foreach ($words as $word) {
      if ($i > 0) {
        $query .= " OR ";
      }
      $query .= "description LIKE '%{$word}%' OR title LIKE '%{$word}%'";
 
      $i++;
    }
    $query .= ")";
Good luck.
 

Basti

Administrator
Staff member
That reminded me that i added new plugin hooks there, totally forgot. On next version you can make a really simple plugin to add new database columns to the code above, but still might be better to have it automatic
 
Top