WPML

Aperçu de l’anomalie

Lors de l’utilisation du widget Post Grid de l’extension Unlimited Elements for Elementor, le widget ne parvient pas à récupérer les articles traduits dans les versions traduites des pages.

Solution de contournement

Ce problème est résolu. La mise à jour vers la dernière version résout le problème sur votre site, vous n’avez donc besoin de cette solution de contournement que si vous ne pouvez pas encore mettre à jour.

Assurez-vous d’avoir une sauvegarde complète de votre site avant de continuer.

  • Ouvrez le fichier functions.php de votre thème.
  • Ajoutez le code suivant :
    PHP
    // WPML Workaround for compsupp-7445
    add_filter( 'elementor/frontend/before_render', 'wpml_compsupp7445_filter_ucaddon_post_grid');
    
    function wpml_compsupp7445_filter_ucaddon_post_grid($element) {
        if ( 'ucaddon_post_grid' !== $element->get_name() ) {
            return;
        }
    
        $settings = $element->get_settings();
    
        if ( isset( $settings['post_list_manual_select_post_ids'] ) && is_array( $settings['post_list_manual_select_post_ids'] ) ) {
            foreach ( $settings['post_list_manual_select_post_ids'] as $key => $id ) {      
    
                $post_type = get_post_type( $id );
    
                if ( ! $post_type ) {
                    continue;
                }
    
                $id = apply_filters( 'wpml_object_id', $id, $post_type, false );
    
                unset($settings['post_list_manual_select_post_ids'][$key]);
                $settings['post_list_manual_select_post_ids'][] = $id;
            }
    
            $element->set_settings( 'post_list_manual_select_post_ids', $settings['post_list_manual_select_post_ids'] );
        }
    
        if (isset($settings['post_list_manual_post_ids_dynamic'])) {
            // Check if the IDs are in a string and convert them to an array
            if (is_string($settings['post_list_manual_post_ids_dynamic'])) {
                $settings['post_list_manual_post_ids_dynamic'] = explode(',', $settings['post_list_manual_post_ids_dynamic']);
            }
    
            // Proceed only if it's an array
            if (is_array($settings['post_list_manual_post_ids_dynamic'])) {
                foreach ($settings['post_list_manual_post_ids_dynamic'] as $key => $id) {
                    $post_type = get_post_type($id);
                    if (!$post_type) {
                        continue;
                    }
                    $translated_id = apply_filters('wpml_object_id', $id, $post_type, false);
                    $settings['post_list_manual_post_ids_dynamic'][$key] = $translated_id;
                }
                $element->set_settings('post_list_manual_post_ids_dynamic', $settings['post_list_manual_post_ids_dynamic']);
            }
        }	
    }

Toutes les anomalies connues

Vous rencontrez toujours ce problème ?

Si la mise à jour ne résout pas le problème, faites une demande d’assistance et nous l’examinerons avec vous.