This filter allows you to translate a set of strings that are otherwise not translatable using __() or _e(). These strings are dynamic, “in-database” strings, so WPML or Polylang cannot see them.

Translatable strings

The following strings can be translated with the facetwp_i18n hook. For an example of how to use it, see below.

Facet type Option / string
Dropdown facet Default label
Radio facet Default label
fSelect facet Default label
Hierarchy facet Default label
Slider facet Reset text
Search facet Placeholder text
Autocomplete facet Placeholder text
Date Range facet Placeholder texts
Pager facet
Type: Page numbers Dots label
Prev button label
Next button label
Type: Result counts Count text (plural)
Count text (singular)
Count text (no results)
Type: Load more Load more text
Loading text
Type: Per page Default label
“Show all” text (if a non-numberic option is added in the settings)
Reset facet Reset text
Sort facet Default label
All sort option labels
Hierarchy Select facet Depth labels
Time Since facet Choices labels
Default label
A-Z Listing Default label
All facet types Facet labels (which appear as headings/labels in the Mobile Flyout and as labels in User Selections)


  • $string | string | The string to translate

Usage example

Add the following code (adapted with your translated strings) to your (child) theme’s functions.php.

In this example, the default language is English and the code gives translations for 2 strings, for the 2 non-default languages, in this case Spanish (‘es’) and German (‘de’). You should only list the non-default language(s), and use the strings as used in the default language (in this case the English ‘Any’ and ‘Enter keywords’). These are the strings as they are set by default in FacetWP’s code, or in each facet’s settings (for example the Placeholder text you can set in the Search facet’s settings).

Also important for this to work is that any strings you set in your facets’ settings are in the default language. Last but not least: the strings need to match exactly, including capitalization and spaces.

How to use custom PHP code?

PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More info

add_filter( 'facetwp_i18n', function( $string ) { if ( isset( FWP()->facet->http_params['lang'] ) ) { $lang = FWP()->facet->http_params['lang']; $translations = []; $translations['es']['Any'] = 'Cualquier'; $translations['de']['Any'] = 'Jeder'; $translations['es']['Enter keywords'] = 'Introduzca las palabras clave'; $translations['de']['Enter keywords'] = 'Geben Sie Schlüsselwörter'; if ( isset( $translations[ $lang ][ $string ] ) ) { return $translations[ $lang ][ $string ]; } } return $string; });

More examples

See also