[Geschlossen] WPML Elasticpress: No posts found for EN index
Dies ist das technische Support-Forum für WPML – das mehrsprachige WordPress-Plugin.
Mitlesen können alle, doch nur WPML-Kunden können hier Fragen veröffentlichen. Das WPML-Team antwortet im Forum an 6 Tagen pro Woche, 22 Stunden am Tag.
Heute stehen keine Supporter zur Arbeit im German-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.
Sun
Mon
Tue
Wed
Thu
Fri
Sat
-
8:00 – 13:00
9:00 – 13:00
9:00 – 13:00
8:00 – 12:00
8:00 – 12:00
-
-
14:00 – 17:00
14:00 – 18:00
14:00 – 18:00
13:00 – 17:00
13:00 – 17:00
-
Unterstützt die Zeitzone: Europe/Zagreb (GMT+02:00)
i'm using the latest versions of WordPress, WPML, Elasticpress and WPML Elasticpress. I have several custom queries (get_posts()) with the "ep_integrate" parameter in order to run the query through Elasticsearch.
While content in the main language (DE) is queried correctly, content the the secondary language (EN) does not return any results. I've run the Elasticpress indexer and there's an DE and EN index, no errors while syncing.
Does WPML elasticpress support the ep_integrate parameter?
In my opinion "WPML ElasticPress" should handle this automatically, mapping WPML's current language to the correct ElasticPress index without additional code.
Other than that I don't have more info about ep_integrate so I would need to check this with our 2nd tier.
I am wondering if something like this would help though?
add_filter('ep_formatted_args', function($formatted_args, $args) {
// Retrieve the current language code using WPML's recommended method
$current_language = apply_filters('wpml_current_language', NULL);
if ($current_language) {
// Construct the index name dynamically based on the current language
// Assuming a naming convention like 'your_prefix-post-1-<language_code>'
$index_prefix = 'your_prefix-post-1'; // Adjust this prefix according to your actual index naming convention
$language_code = $current_language; // Use the WPML function to get the current language code
// Check if the current language is English
if ($language_code === 'en') {
// Construct the full index name for English content
$english_index = $index_prefix . '-' . $language_code;
// Update the query to use the dynamically constructed English index name
$formatted_args['index'] = $english_index;
}
// Extend this logic for other languages as needed
}
return $formatted_args;
}, 10, 2);
Remember to replace 'your_prefix-post-1' with the actual prefix used in your Elasticsearch index names. This strategy ensures that all queries going through ElasticPress will automatically target the correct index for English content based on the current WPML language setting, without needing to specify exact index names in your code.
Regards,
Bruno Kos
Das Thema '[Geschlossen] WPML Elasticpress: No posts found for EN index' ist für neue Antworten geschlossen.