german umlauts and pinning | WordPress.org

Yes. Depending on your database setup, you need one of these:

add_filter( 'relevanssi_remove_punctuation', function( $string ) {
  $chars = array(
    'ü' => 'u',
    'ä' => 'a',
    'ö' => 'o',
    'Ü' => 'U',
    'Ä' => 'A',
    'Ö' => 'O',
  );
  return strtr( $string, $chars );
}, 8 );

or

// From a theme:
remove_filter( 'relevanssi_remove_punctuation', 'remove_accents', 9 );

// From a plugin:
add_action( 'init', function() {
  remove_filter( 'relevanssi_remove_punctuation', 'remove_accents', 9 );
} );

You need the first one if your database ignores accents (i.e. searching for “mädchen” and “madchen” get the same results from the database) and the second one, if your database cares about accents (“mädchen” and “madchen” get different results).

that’s working fine, we are looking for a solution to find a result searching for “maedchen” as well. any idea ?

  • This reply was modified 14 hours, 6 minutes ago by janhamer.

Here’s one method. This hooks into the indexing process and indexes words with ä, ö and ü both ways, so “mädchen” will be indexed both as “mädchen” and “maedchen”. Add this to theme functions.php and reindex:

add_filter( 'relevanssi_indexing_tokens', function( $tokens ) {
    $new_tokens = array();
    foreach ( $tokens as $token => $tf ) {
        if ( strpos( $token, 'ä' ) !== false ) {
            $new_tokens[ str_replace( 'ä', 'ae', $token ) ] = $tf;
        }
        if ( strpos( $token, 'ö' ) !== false ) {
            $new_tokens[ str_replace( 'ö', 'oe', $token ) ] = $tf;
        }
        if ( strpos( $token, 'ü' ) !== false ) {
            $new_tokens[ str_replace( 'ü', 'ue', $token ) ] = $tf;
        }
    }
    return array_merge( $tokens, $new_tokens );
} );

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer