• Resolved kiriakos1988

    (@kiriakos1988)


    Hello,

    First of all i would like to thank you for your awesome plugin! i am using it a long time and it rocks!
    Recently i discovered an issue with the user searches count results that i need your help.

    I am using the DIVI theme and i used this shortcode to place a search input with category filters on the sites menu [searchform dropdown=”category”].

    I noticed that when the user does not select one category and leaves the default “none”(cat-1) on category dropdown then on the results page it shows that there were 2 searches instead of one.

    After some searching in Network tab on chrome DevTools i found out that when i search a string with no category selected then there is a 301 redirect posted that has a result to count the search 2 times
    1st request -> ?s=test&cat=-1 (status 301)
    2nd request -> ?s=test (status 200)

    As the correct search reports are very critical to me Is there anything i can do to prevent this from happening?

    Thanks in advanced

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

    (@msaari)

    This doesn’t happen on my test site, so it’s likely something specific to your site.

    That -1 value for “none” is not good with Relevanssi, by the way… Relevanssi interprets that as “not category 1”, which is not the same as “none”. For Relevanssi, the none value should be 0. That’s a bug in Relevanssi I’ll have to fix.

    Try adding this to your theme functions.php:

    add_filter( 'relevanssi_search_form', function( $form ) {
        return str_replace( "value='-1'", "value='0'", $form );
    });

    Does that fix your problem?

    Thread Starter kiriakos1988

    (@kiriakos1988)

    Hello and thanks for the fast reply!
    I want to clarify that this issue is reproduced only with the use of the shortcode [searchform dropdown=”category”].
    if i use the default divi search everything runs fine.

    Anyway with your function the issue is resolved so thanks for that, i am covered!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘search counts more than one’ is closed to new replies.