Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client is experiencing very slow performance on their website. A PHP X-Ray report identified WPML as the root cause. Despite updating WPML from version 4.6.12 to 4.6.13, the issue persisted.
Solution:
We discovered that the slow performance was due to specific theme code in

wp-content/themes/website_international_NEW/functions.php

. The problematic code is a function designed to update the focus keyword for all posts of a certain type on every page load. Here is the code:

// Function to automatically update the focus keyword for all: sights<br />function update_focus_keywords_sights()<br />{<br />    $posts = get_posts(array(<br />        'posts_per_page'    => -1,<br />        'post_type'        => 'sights' //replace post with the name of your post type<br />    ));<br />    foreach ($posts as $p) {<br />        update_post_meta($p->ID, 'rank_math_focus_keyword', strtolower(get_the_title($p->ID)));<br />    }<br />}<br />add_action('init', 'update_focus_keywords_sights');

Removing this code reduced the site's load time from approximately 17 seconds to 4.5 seconds. We recommend removing or optimizing this function to improve performance.

If this solution does not apply to your case, or if it seems outdated, please check the related known issues and confirm that you have installed the latest versions of themes and plugins. If the problem persists, we highly recommend opening a new support ticket at WPML support forum.

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.

Tagged: 

This topic contains 21 replies, has 2 voices.

Last updated by Paola Mendiburu 1 month, 1 week ago.

Assisted by: Paola Mendiburu.

Author Posts
September 16, 2024 at 2:27 pm #16184422

Paola Mendiburu
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

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

I will escalate it to the second tier.

September 19, 2024 at 7:36 am #16196338

Paola Mendiburu
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

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

The credentials from chat has been deleted.

Could you please add the credentials again so the second tier can investigate?

I have enabled next answer as private.

The private box looks like this: hidden link

September 19, 2024 at 7:43 am
September 19, 2024 at 1:53 pm #16199176

Paola Mendiburu
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

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

I have escalated to the second tier with all the details.

I will let you know when I have some news.

October 3, 2024 at 9:32 am #16248611

olivierA-13

Hi Paola

I hope you are well. It has been some time since the last update, are there any news for this case?

Best regards
Levin

October 3, 2024 at 11:48 am #16249536

Paola Mendiburu
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

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

Hi there!

I just got a response from the second level.

The issue is caused by the theme code in - wp-content/themes/website_international_NEW/functions.php
there is this code:


// Function to automatically update the focus keyword for all: sights
function update_focus_keywords_sights()
{
    $posts = get_posts(array(
        'posts_per_page'    => -1,
        'post_type'        => 'sights' //replace post with the name of your post type
    ));
    foreach ($posts as $p) {
        update_post_meta($p->ID, 'rank_math_focus_keyword', strtolower(get_the_title($p->ID)));
    }
}
add_action('init', 'update_focus_keywords_sights');

With that code in place, the site loads for me for 17secs rougly.
With that code removed, it loads for 4.5secs.

The workaround is to remove the code.

October 4, 2024 at 8:21 am #16252877

olivierA-13

Hi Paola

Thanks for the finding.
It is a bit unfortunate because we identified this exact code snippet a week ago, and removed it on production - and indeed it made the load time much faster; but still (as you reported) we have a long load time of many seconds.
Is there anything else from WPML side which can be done to bring the load time down?
It specifically affects pages from the shop (WooCommerce) in combination with WPML.

Best regards
Levin

October 6, 2024 at 3:59 pm #16258186

Paola Mendiburu
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

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

Hi Levin,

I have transfer that to the second tier.

I will let you know when I have some news.

October 17, 2024 at 7:56 am #16298613

olivierA-13

Hi Paola

It has been some time since our last conversation, and Explorial unfortunately still struggles with quite a slow response time.
Have there been any findings on WPML's side?

Thanks and best regards
Levin

October 18, 2024 at 8:17 am #16303208

Paola Mendiburu
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

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

Hi there!

Sorry for the delay.

Please try to disable the mu-plugins:

Activity Log Plugin
CDN Cache Plugin

If the issue persists, try to disable all caching plugins and also the plugin: AffiliateWP (just to rule out cache and that plugin) and see if that helps and report back with the results.