"The Grid's" WPML Meta Query is slowing down my site heavily

Hi there,

i have a customer-website running with WPML, Woocommerce and Themeco’s “Pro” Theme. For custom product-grids i use the plugin “The Grid” which is involved in Themeco’s Plugin bundle. It is marked as “WPML-compatible” but unfortunately the mix of WPML and The Grid is slowing down my site heavily because of the following string:

SELECT sawp_posts.*
FROM sawp_posts
LEFT JOIN sawp_postmeta
ON ( sawp_posts.ID = sawp_postmeta.post_id )
LEFT JOIN sawp_postmeta AS mt1
ON (sawp_posts.ID = mt1.post_id
AND mt1.meta_key = 'the_grid_language' ) JOIN sawp_icl_translations t
ON sawp_posts.ID = t.element_id
AND t.element_type = CONCAT('post_', sawp_posts.post_type)
WHERE 1=1
AND ( ( ( sawp_postmeta.meta_key = 'the_grid_language'
AND sawp_postmeta.meta_value LIKE '%de%' )
OR mt1.post_id IS NULL ) )
AND sawp_posts.post_type = 'the_grid'
AND ((sawp_posts.post_status <> 'trash'
AND sawp_posts.post_status <> 'auto-draft'
AND sawp_posts.post_status <> 'tco-data'))
AND ( ( ( t.language_code = 'de'
OR 0 )
AND sawp_posts.post_type IN ('post','page','attachment','custom_css','customize_changeset','oembed_cache','cs_header','cs_footer','cs_user_templates','global-blocks','invoice','product','product_variation','shop_order_refund','wpcf7_contact_form','the_grid','wpsl_stores','mc4wp-form','x-portfolio' ) )
OR sawp_posts.post_type NOT IN ('post','page','attachment','custom_css','customize_changeset','oembed_cache','cs_header','cs_footer','cs_user_templates','global-blocks','invoice','product','product_variation','shop_order_refund','wpcf7_contact_form','the_grid','wpsl_stores','mc4wp-form','x-portfolio' ) )
GROUP BY sawp_posts.ID
ORDER BY sawp_posts.post_modified DESC

–> This Query is loaded THREE times and takes 1,5 seconds each (although using w3tc).

I found the regarding code inside “wpml.class.php” inside the “The Grid” Plugin folder:

public static function WPML_meta_query() {

$WPML_meta_query = null;

if(self::WPML_exists()) {

$WPML_current_lang = self::WPML_current_lang();
$WPML_default_lang = self::WPML_default_lang();
$WPML_current_lang = ($WPML_current_lang == 'all') ? '' : $WPML_current_lang;
$WPML_not_exist = array(
'key' => 'the_grid_language',
'value' => '',
'compare' => 'NOT EXISTS'
);
$WPML_not_exist = (($WPML_current_lang == $WPML_default_lang) || empty($WPML_current_lang)) ? $WPML_not_exist : null;
$WPML_meta_query = array (
'relation' => 'OR',
array(
'key' => 'the_grid_language',
'value' => $WPML_current_lang,
'compare' => 'LIKE'
),
$WPML_not_exist
);

}

return $WPML_meta_query;

}

–> When i delete it, the site runs much faster but the translation of the grids do not work anymore… Is there a simple way how i can edit this code so the query is still working but maybe MUCH faster? :wink:

I’m looking forward to hearing from you all soon!

Best regards from Germany,
Max

P.S.: I would have loved to ask the support of “The Grid” about it but i cannot acces their support-area is i need to provide an ENVATO purchase code -.-

Hello @meksme,

Thanks for asking. :slight_smile:

Unfortunately, it fall outside the scope of our support to customize the functioning of plugin. I suggest you get in touch with a developer to make the necessary changes.

Thanks for understanding.

Hi @Prasant, thank you for that quick answer!
I found a solution by myself but i also have another query, which is a cornerstone related query:

SELECT COUNT(id)
FROM sawp_icl_strings
WHERE context = 'cornerstone'

Maybe you can help me with that? It takes 0,5 seconds to load!

Best regards,
Max

Hi @meksme,

At this time, I could not suggest or give code due to its complexity. I could not guarantee that we could help you with this however I will forward this issue to our developer and soon our developer will get back to you.

Thank you so much for understanding.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.