Skip Navigation

[Resolved] Filter problem with wpml

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

Problem:

The issue here is that after the User uses the views AJAX filters his posts don't show in the correct language

Solution:

This is possible due to the "Language filtering for AJAX operations" not being enabled in WPML.

Could you go to Toolset-> Language and scroll down to the Language filtering for AJAX operations settings.

This support ticket is created 6 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 2 replies, has 2 voices.

Last updated by glenn 6 years, 7 months ago.

Assisted by: Shane.

Author
Posts
#918764

I am trying to: get results from a view in the right language.

Link to a page where the issue can be seen:
hidden link

When you change a category it gives back results in dutch(default). It seems that the language url parameter is not added to the filtered url result. It used to work fine but it seems an update caused this functionality to break.

The url it gives back is: hidden link

Where it should(and used to be): hidden link

I expected to see:
hidden link

Instead, I got:
hidden link

FYI, my PHP specialist wrote a custom function back when we build the website to set the correct URL.

add_filter('icl_ls_languages', 'wpml_ls_filter');
function wpml_ls_filter($languages)
{
global $sitepress;
if($_SERVER["QUERY_STRING"])
{
if(strpos(basename($_SERVER['REQUEST_URI']), $_SERVER["QUERY_STRING"]) !== false)
{
$queryString = preg_replace('/-[a-z]{2}$/i', '', $_SERVER['QUERY_STRING']);
$queryString = preg_replace('/lang=[a-z]{2}\&?/i', '', $queryString);

foreach($languages as $lang_code => $language)
{
if(strpos($languages[$lang_code]['url'], '?') !== false)
{
$queryString = str_replace('?', '&', $queryString);
$languages[$lang_code]['url'] = $languages[$lang_code]['url'].$queryString . '-' . $lang_code;
}
else
{
$queryString = '?'.$queryString;
$languages[$lang_code]['url'] = $languages[$lang_code]['url'].$queryString;
}
}
}
}
return $languages;
}

Can you help me to get this functionality back?

#918896

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Glenn,

Thank you for contacting our support forum.

This is possible due to the "Language filtering for AJAX operations" not being enabled in WPML.

Could you go to Toolset-> Language and scroll down to the Language filtering for AJAX operations settings.

Thanks,
Shane

#919260

Hi Shane,

that was it! Thanks for pointing it out to me. Weird that the setting was changed somehow.

Kind regards and have a good weekend.