• Resolved katiewsi

    (@katiewsi)


    Hi,

    Love your plugin, so thank you!

    We seem to be having an issue where weighting is working in the admin search you suggest checking, but in the front-end search it is showing something different. The admin search shows the correct order based on the weighting options.

    Content: 5
    Titles: 100
    Comment Text: 1
    Tag weight: 1
    Category weight: 50

    Not sure what is going on, I have disabled cache and that doesn’t work? We’re using Elementor template for the search…?

    Thanks so much,
    Katie

    The page I need help with: [log in to see the link]

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

    (@msaari)

    Remove the e_search_props parameter from the search. That’s what is ruining the search results.

    You can remove the parameter from the search form, or you can try disabling it with this snippet:

    add_filter( 'relevanssi_modify_wp_query', function( $query ) {
    $query->set( 'e_search_props', '' );
    return $query;
    } );
    Thread Starter katiewsi

    (@katiewsi)

    Thanks for the super speedy reply!

    I tried the snippet and that didn’t work…

    Many thanks,
    Katie

    Plugin Author Mikko Saari

    (@msaari)

    If that doesn’t work, then you somehow need to remove this field from your search form:

    <input type="hidden" name="e_search_props" value="2022cce-8100">

    You can ask Elementor support about this; it would be good if they get feedback that this is causing problems with third-party plugins and they need to make it possible to remove this field.

    Thread Starter katiewsi

    (@katiewsi)

    Elementor haven’t got a fix, told me they will add it as a feature request…

    Thread Starter katiewsi

    (@katiewsi)

    This JavaScript works for anyone experiencing the same issue:

    if (window.location.search.indexOf('e_search_props') !== -1) {
    var url = new URL(window.location.href);

    // Remove the 'e_search_props' parameter
    url.searchParams.delete('e_search_props');

    // Redirect to the new URL without the 'e_search_props' parameter
    window.location.replace(url);
    }
    Plugin Author Mikko Saari

    (@msaari)

    Very good, thanks!

    I had the same problem— the title wasn’t getting proper weighting. I used @katiewsi’s snippet, but I modified it a bit because it was causing a redirect in my case. Here is the code I used in functions.php:

    function add_custom_script() {
    ?>
    <script>
    (function() {
    if (window.location.search.indexOf('e_search_props') !== -1) {
    var url = new URL(window.location.href);

    url.searchParams.delete('e_search_props');

    window.location.replace(url.href);
    }
    })();
    </script>
    <?php
    }
    add_action('wp_head', 'add_custom_script');

    Another option is to use the Elementor Pro Code Editor:

    Go to: Elementor → Custom Code → Add New
    Set Location: <body> – Start
    Add the following script:

    <script>
    document.addEventListener('DOMContentLoaded', function() {
    var hiddenField = document.querySelector('input[name="e_search_props"]');
    if (hiddenField) {
    hiddenField.remove();
    }
    });
    </script>
    • This reply was modified 2 weeks, 4 days ago by liikalat. Reason: added another solution
Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.