Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 -
- 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 -

Supporter timezone: Europe/Zagreb (GMT+01:00)

Tagged: 

This topic contains 3 replies, has 1 voice.

Last updated by Dražen 2 days, 3 hours ago.

Assisted by: Dražen.

Author Posts
February 22, 2025 at 12:12 pm #16736234

danielE-41

Background of the issue:
I am trying to translate a widget and avoid seeing a white screen. The issue can be seen on the translated page: hidden link. The original page is: hidden link.

Symptoms:
I am seeing a blank screen on the translated page.

Questions:
Why am I seeing a blank screen when using this code on translation?
How can I translate the widget without encountering a white screen?

hidden link

February 23, 2025 at 3:03 pm #16738108

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

Welcome to WPML support. I am going to answer his question before the ticket is assigned to one of my colleagues.

Would you please kindly follow the steps below to provide the debug information?

https://wpml.org/faq/provide-debug-information-faster-support/

Also I wonder if the widget that you talk about is something that you add from WP Dashboard > Appearance > Widgets?

If so, would you please test by adding two instances of the widget and select the proper language for each by checking the documentation below?

https://wpml.org/documentation/getting-started-guide/translating-widgets/#display-different-widgets-each-language

If that is not the problem, please clarify what do you mean by widget, how do you add the widget and what is the name of the plugin/theme that enables the widget.

Thanks

February 24, 2025 at 5:50 am #16738949

danielE-41

below is my elementor widget code witch i am unable to translate:
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

class Case_Studies_Widget extends \Elementor\Widget_Base {

public function get_name() {
return 'related-case-study';
}

public function get_title() {
return __( 'Case Studies', 'essentials' );
}

public function get_icon() {
return 'eicon-posts-group';
}

public function get_categories() {
return [ 'general' ];
}

protected function _register_controls() {
$this->start_controls_section(
'content_section',
[
'label' => __( 'Content', 'essentials' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
]
);

// Case Studies Post Selector
$this->add_control(
'selected_posts',
[
'label' => __( 'Select Case Studies', 'essentials' ),
'type' => \Elementor\Controls_Manager::SELECT2,
'options' => $this->get_case_study_posts(),
'multiple' => true,
'label_block' => true,
]
);

// Case Studies Heading Tag
$this->add_control(
'post_heading_tag',
[
'label' => __( 'Select Post Heading Tag', 'essentials' ),
'type' => \Elementor\Controls_Manager::SELECT2,
'options' => array( 'h1' => 'H1', 'h2' => 'H2', 'h3' => 'H3', 'h4' => 'H4', 'h5' => 'H5', 'h6' => 'H6' ),
'multiple' => false,
'label_block' => true,
]
);

$this->end_controls_section();
}

private function get_case_study_posts() {
$posts = get_posts([
'post_type' => 'case-study', // Static post type
'posts_per_page' => -1,
// 'suppress_filters' => false
]);

$options = [];
if ( $posts ) {
foreach ( $posts as $post ) {
$options[$post->ID] = $post->post_title;
}
}

return $options;
}

public function render() {

$settings = $this->get_settings_for_display();

if ( empty( $settings['selected_posts'] ) ) {
echo '<p>'. __( 'No case studies selected.', 'essentials-child' ) .'</p>';
return;
}

$post_heading_tag = ! empty( $settings['post_heading_tag'] ) ? $settings['post_heading_tag'] : 'h3';

$query_args = array(
'post_type' => 'case-study',
'post__in' => $settings['selected_posts'],
'orderby' => 'post__in',
);

$query = new WP_Query( $query_args );

if ( $query->have_posts() ) {

$found_posts = $query->found_posts;
$single_class = '';
if ( $found_posts == 1 ) {
$single_class = 'single_slide';
}

echo ' <div class="casestudy_block">
<div class="cs_slider '. $single_class .'">';
while ( $query->have_posts() ) {
$query->the_post();
global $post;
$post_id = $post->ID;
$company_logo = get_field( 'case_study_company_logo', $post_id );
$company_description = get_field( 'case_study_company_description', $post_id );
$author_name = get_field( 'case_study_author_name', $post_id );
$author_image = get_field( 'case_study_author_image', $post_id );
$author_designation = get_field( 'case_study_author_designation', $post_id );
$author_description = get_field( 'case_study_author_description', $post_id );

if ( get_the_excerpt( $post ) ) {
$post_excerpt = wp_trim_words( get_the_excerpt( $post ), 60, '' );
} else if ( get_the_content( $post ) ) {
$post_excerpt = wp_trim_words( get_the_content( $post ), 60, '' );
}

echo '<div class="cs_slide">
<div class="cs_boxrow">
<div class="cs_boxleft">
<div class="cs_box_deatils">';
if ( ! empty( $company_logo ) ) {
echo '<div class="cs_box_companylogo">
<img src="'. esc_url( $company_logo['url'] ) .'" alt="'. esc_attr( $company_logo['alt'] ) .'" />
</div>';
}
echo '<div class="cs_box_innerdeatils">';
echo '<' . $post_heading_tag . ' class="cs_boxtitle">'. get_the_title() .'</'. $post_heading_tag .'>';
// echo '<h3 class="cs_boxtitle">'. get_the_title() .'</h3>';
if ( ! empty( $post_excerpt ) ) {
echo '<div class="cs_box_excerpt">'. $post_excerpt .'</div>';
}
echo '<div class="cs_box_readmore">


</div>
</div>
</div>';
if ( ! empty( $author_name ) ) {
echo '<div class="cs_author_row">';
if ( ! empty( $author_image ) ) {
echo '<img src="'. esc_url( $author_image['url'] ) .'" alt="'. esc_attr( $author_image['alt'] ) .'" />';
} else if ( ! empty( $company_logo ) ) {
echo '<img src="'. esc_url( $company_logo['url'] ) .'" alt="'. esc_attr( $company_logo['alt'] ) .'" />';
} else {
$placeholder_image_author = get_field( 'placeholder_image_for_author', 'options' );
if ( ! empty( $placeholder_image_author ) ) {
echo '<img src="'. esc_url( $placeholder_image_author['url'] ) .'" alt="'. esc_attr( $placeholder_image_author['alt'] ) .'" />';
}
}
if ( ! empty( $author_name ) || ! empty( $author_designation ) ) {
echo '<div class="cs_author_rowdeatils">';
if ( ! empty( $author_name ) ) {
echo '<div class="authortitle" role="heading" aria-level="3">'. $author_name .'</div>';
}
if ( ! empty( $author_designation ) ) {
echo '<div class="authordesignation">'. $author_designation .'</div>';
}
echo '</div>';
}
echo '</div>';
}
echo '</div>
<div class="cs_boxright">';
if ( has_post_thumbnail( $post ) ) {
echo get_the_post_thumbnail( $post, 'full' );
} else {
$placeholder_image = get_field( 'placeholder_image_for_posts', 'options' );
if ( ! empty( $placeholder_image ) ) {
echo '<img src="'. esc_url( $placeholder_image['url'] ) .'" alt="'. esc_attr( $placeholder_image['alt'] ) .'" />';
}
}
echo '</div>
</div>
</div>';
}
echo '</div>
</div>';
wp_reset_postdata();
} else {
echo '<p>'. __( 'No case studies found.', 'essentials-child' ) .'</p>';
}
}
}

February 26, 2025 at 8:44 am #16749667

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

thanks for getting back.

1) Is this a custom-coded widget that you developed or how are you adding this to your website?

2) I have checked URL shared and I can see it working fine. Do you still have issue?

Regards,
Drazen

Test für Widget-Übersetzung - Spitch.jpg