I was using a custom query and didn't realize that ID of the translated CPT is different from the original one.
Here is my updated custom query :
// Ajouter un filtre pour filtrer par IDs dans Elementor Pro avec support WPML
function custom_query_by_post_team( $query ) {
// Définir les IDs que tu veux filtrer dans la langue d'origine
$post_ids = array( 73053, 73072, 73245, 73149, 73195, 73035, 73058, 73141, 73065, 73140, 72962, 73138, 73027 ); // membres à afficher
// Récupérer la langue actuelle via WPML
$current_lang = apply_filters( 'wpml_current_language', null );
// Traduire les IDs des membres d'équipe dans la langue actuelle
$translated_post_ids = array_map(function($id) use ($current_lang) {
return icl_object_id($id, 'team-member', true, $current_lang); // Adapter 'team-members' à ton type de publication
}, $post_ids);
// Appliquer le filtre post__in avec les IDs traduits
if ( !empty($translated_post_ids) ) {
$query->set( 'post__in', $translated_post_ids );
$query->set( 'orderby', 'title' ); // Trier par titre (title)
$query->set( 'order', 'ASC' ); // 'ASC' pour ordre alphabétique croissant, 'DESC' pour ordre décroissant
}
}
// Appliquer ce filtre dans Elementor via le hook "elementor/query"
add_action( 'elementor/query/my_custom_team_query', 'custom_query_by_post_team' );
Manage Cookie Consent
We use cookies to optimize our website and services. Your consent allows us to process data such as browsing behavior. Not consenting may affect some features.
Functional
Always active
Required for our website to operate and communicate correctly.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
We use these to analyze the statistics of our site. Collected information is completely anonymous.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
These cookies track your browsing to provide ads relevant to you.