Relevanssi - A Better Search
[resolved] Duplicate Results w/ WPML (8 posts)

  1. zitrusblau
    Posted 2 years ago #


    we found that using Relevanssi + WPML would give us duplicate results (not mixed up results, just plain duplicates on the result list).

    So after investigating a bit, we solved it for us by uncommenting this part in function "relevanssi_wpml_filter" in common.php:

    if (function_exists('icl_object_id') && function_exists('pll_is_translated_post_type')) {
    				if (pll_is_translated_post_type($hit->post_type)) {
    				    if ($hit->ID == icl_object_id($hit->ID, $hit->post_type,false,ICL_LANGUAGE_CODE))
    				        $filtered_hits[] = $hit;

    seems like the condition is true for both WPML and Polylang as well.

    Would be nice if you could address this issue in one of your next update.



  2. Mikko Saari
    Plugin Author

    Posted 2 years ago #

    Yes, this is a known bug and will be fixed in the next version.

    Could you please check one thing for me - does it work if you change the if on that block to elseif?

    So, elseif (function_exists('icl_object_id') && function_exists('pll_is_translated_post_type')) { and so on - does that work?

  3. zitrusblau
    Posted 2 years ago #

    hey Mikko,

    easy fix. yes it works with an "elseif" statement!


  4. cob-web
    Posted 2 years ago #

    This saved my weekend! Thanks for that! :-D

  5. kathatp
    Posted 1 year ago #

    I recently installed Version 3.3.4 and the duplication problem was there again.

    Fixed it by replacing the if with elseif on line 28


    elseif (function_exists('icl_object_id') && !function_exists('pll_is_translated_post_type')) {

    Maybe you could add that into the next release. cheers.

  6. Mikko Saari
    Plugin Author

    Posted 1 year ago #

    Yes, there was a bug in 3.3.4 with extra code remaining. This is actually already fixed - you can go download the Development version from the Developers tab, and that version already fixes the bug.

  7. RobinWebber
    Posted 1 year ago #

    Hi there,

    I've the latest version of Relevanssi, but still get duplicate results on the search page. I see the 'elseif' statement in the code, so that can't be the problem.

    Hope you can help!

  8. RobinWebber
    Posted 1 year ago #

    My mistake! Didn't see this checkbox yet:

    Limit results to current language: If this option is checked, Relevanssi will only return results in the current active language. Otherwise results will include posts in every language.

    It works perfectly now, thanks!!

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