WPML
状态
等待作者
相关插件/主题
Unlimited Elements for Elementor
主题标签
Compatibility

问题概述

在带有 WPML 的站点上使用 Unlimited Elements for Elementor 插件中的 Post Carousel 小工具时,该小工具无法获取已翻译的文章,从而导致已翻译的页面上出现内容显示问题。

临时解决方法

在继续操作之前,请确保您的站点拥有完整备份


  • 打开您主题的 functions.php 文件。

  • 添加以下代码:
    // WPML Workaround for compsupp-7126
    add_filter( 'elementor/frontend/before_render', 'wpml_compsupp7126_filter_ucaddon_post_carousel');
    
    function wpml_compsupp7126_filter_ucaddon_post_carousel($element) {
        if ( 'ucaddon_post_carousel' !== $element->get_name() ) {
            return;
        }
    
        $settings = $element->get_settings();
    
        if ( isset( $settings['post_manual_select_post_ids'] ) && is_array( $settings['post_manual_select_post_ids'] ) ) {
            foreach ( $settings['post_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, true );
    
                unset($settings['post_manual_select_post_ids'][$key]);
                $settings['post_manual_select_post_ids'][] = $id;
            }
    
            $element->set_settings( 'post_manual_select_post_ids', $settings['post_manual_select_post_ids'] );
        }
    }

所有已知问题 →