Skip to main contentSkip to footer

Polylang Pro has a feature to sync translations between posts. The problem with this and Relevanssi is that Relevanssi does not index the changes to the synced posts. With this filter function added to your site, Relevanssi will also index the synced posts:

add_action( 'save_post', 'index_post_in_all_languages' );
function index_post_in_all_languages( $post_id ) {
    if ( ! function_exists( 'pll_languages_list' ) ||
     ! function_exists( 'relevanssi_insert_edit' ) ) {
        return;
    }
    $all_languages      = pll_languages_list( ['fields' => 'slug'] );
    $post_language      = pll_get_post_language( $post_id, 'slug' );
    $languages_to_index = array_diff( $all_languages, [ $post_language] );
    foreach ( $languages_to_index as $lang ) {
        $post_id_to_index = pll_get_post( $post_id, $lang );
        if ( $post_id_to_index > 0 ) {
            relevanssi_insert_edit( $post_id_to_index );
        }
    }
}

Thanks to Nico von Niederhäusern / Cubetech.

There’s also a method for indexing WPML synced posts.

Your account

Not logged in. Log in to see your license details.

Search

Popular Resources

Wildcard matching
Relevanssi Premium 2.10.2 introduces a new way to search: wildcard matching. Once the wildcard matching is enabled (it is disabled…
Relevanssi and languages

Relevanssi is language-agnostic in itself. It does not know any language and doesn’t care about which language the site uses. However, there are a few things that you need to consider when using Relevanssi in languages other than English. Characters: use UTF8 As long as your site uses UTF8 characters,……mean” suggestions in Relevanssi Premium only support Latin characters. The way these suggestions work is that when Relevanssi searches, Relevanssi then modifies the search term in different ways by adding or removing letters in it. Relevanssi does these modifications with the Latin alphabet (mainly the English alphabet, with a few…

Related Posts:

Comment Section:

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed