تخطي الملاحة

Waiting for author

Topic Tags: Compatibility

Overview of the issue

When using the Post Carousel widget from the Unlimited Elements for Elementor plugin on a site with WPML, the widget fails to fetch translated posts, leading to content display issues on translated pages.

Workaround

Please, make sure of having a full backup of your site before proceeding.

  • Open your theme’s functions.php file.
  • Add the following code:
    // 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'] );
        }
    }
    

ترك رد

يُرجى البقاء في الموضوع والتزام الاحترام للآخرين. إذا كنت بحاجة إلى مساعدة بشأن المشكلات التي لا تتعلق بهذا المنشور، فاستخدم منتدى الدعم لبدء محادثة أو إرسال تذكرة.

يمكنك استخدام هذه العلامات:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>