• Resolved AliMH

    (@alimh)


    hi,
    i wanna use wordpress internal search engine if relevenssi return no result,but i couldn’t figure it out.
    can you please shed some light on it? and where i can resolve this?
    my main problem is relevanssi cannot find some search terms like ‘k-on’ but wordpress search engine can, so i wanna use it when relevanssi return nothing.

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

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

    (@msaari)

    Why not make Relevanssi find those search terms instead? Just add this code to your theme functions.php and reindex the database:

    add_filter('relevanssi_remove_punctuation', 'rlv_fix_the_problem', 9);
    function rlv_fix_the_problem($a) {
        $a = str_replace('-', '', $a);
        return $a;
    }
    Thread Starter AliMH

    (@alimh)

    oh thanks, it solved my problem

    Thread Starter AliMH

    (@alimh)

    oh, i face a new problem related to this;
    now, no result for ‘Aki Sora’ and i should search for ‘Aki-Sora’.

    Plugin Author Mikko Saari

    (@msaari)

    Well, you can’t have everything… but you can try this:

    add_filter('relevanssi_remove_punctuation', 'rlv_fix_the_problem', 9);
    function rlv_fix_the_problem($a) {
        if (strlen($a) <= 5) {
            $a = str_replace('-', '', $a);
        }
        else {
            $a = str_replace('-', ' ', $a);
        }
        return $a;
    }

    Now if the word is less than six characters long, hyphens are removed, otherwise they are replaced with spaces. So, “k-on” becomes “kon”, while “aki-sora” becomes “aki sora”. That might work better.

    Thread Starter AliMH

    (@alimh)

    lol, good idea, really thanks mate.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘use wordpress internal search engine programmically’ is closed to new replies.