WordPress.org

Forums

Relevanssi - A Better Search
[resolved] use wordpress internal search engine programmically (6 posts)

  1. AliMH
    Member
    Posted 1 year ago #

    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/

  2. Mikko Saari
    Member
    Plugin Author

    Posted 1 year ago #

    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;
    }
  3. AliMH
    Member
    Posted 1 year ago #

    oh thanks, it solved my problem

  4. AliMH
    Member
    Posted 1 year ago #

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

  5. Mikko Saari
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  6. AliMH
    Member
    Posted 1 year ago #

    lol, good idea, really thanks mate.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Relevanssi - A Better Search
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.