Please make sure to update to WPML 4.3.5 and check our list of Known Issues before reporting

Hi, Amit here, I am the WPML Support Manager, our current ticket queue is high, update your WPML plugins and make sure you meet the minimal requirements for running WPML before reporting an issue please - many tickets are resolved doing that

Please look at our updated list of Known Issues and you can also use our support search to find helpful information and of course review our documentation before opening a ticket.

If you do need to open a ticket please make sure to provide us with all the needed information as described in this page

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 11 replies, has 4 voices.

Last updated by Bruno 2 years, 2 months ago.

Assigned support staff: Bruno.

Author Posts
June 13, 2017 at 5:47 am #1296902

thomasK-40

I am trying to:

display german downloads on the german page, and english downloads on the english page.

URL of (my) website where problem appears:

my dev machine, as i had to immediately rollback the live version to 4.7.5 to make it work again.
see screenshots.

this is the live site, where the german downloads appear correctly in 4.7.5.
hidden link

In 4.8, the downloads do not appear. get_posts() delivers array().

I expected to see:

see above.

Instead, I got:

Working english page, empty german page.

Steps to duplicate the issue:

in WP 4.8, the query is

SELECT wp_posts.*
FROM wp_posts
LEFT JOIN wp_term_relationships
ON (wp_posts.ID = wp_term_relationships.object_id) JOIN wp_icl_translations t
ON wp_posts.ID = t.element_id
AND t.element_type = CONCAT('post_', wp_posts.post_type)
WHERE 1=1
AND ( wp_term_relationships.term_taxonomy_id IN (58) )
AND wp_posts.post_type = 'download'
AND ((wp_posts.post_status = 'publish'))
AND ( ( t.language_code = 'de'
AND wp_posts.post_type IN ('post','page','download','news-media','job','glossary-entry' ) )
OR wp_posts.post_type NOT IN ('post','page','download','news-media','job','glossary-entry' ) )
GROUP BY wp_posts.ID
ORDER BY wp_posts.menu_order, wp_posts.post_date DESC

in 4.7.5 it is

SELECT wp_posts.*
FROM wp_posts
LEFT JOIN wp_term_relationships
ON (wp_posts.ID = wp_term_relationships.object_id) JOIN wp_icl_translations t
ON wp_posts.ID = t.element_id
AND t.element_type = CONCAT('post_', wp_posts.post_type)
WHERE 1=1
AND ( wp_term_relationships.term_taxonomy_id IN (68) )
AND wp_posts.post_type = 'download'
AND ((wp_posts.post_status = 'publish'))
AND ( ( t.language_code = 'de'
AND wp_posts.post_type IN ('post','page','download','news-media','job','glossary-entry' ) )
OR wp_posts.post_type NOT IN ('post','page','download','news-media','job','glossary-entry' ) )
GROUP BY wp_posts.ID
ORDER BY wp_posts.menu_order, wp_posts.post_date DESC

So the problem is, that even if i am on the german page, it tries to find german posts in the english download-area (58). i have attached 2 screenshots. younicos.dev is my dev machine.

see the difference in the taxonomy id ? its the same theme code.

i took 5h to find this out ;/ . i hope you find a fix

June 14, 2017 at 12:34 pm #1298169

Bruno
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi,

Thank you for contacting us.

What is the query you are doing to recover these posts from the database? Did you test this with the default WordPress theme?

Please as a test, could you disable all non-WPML plugins and see if the problem persists? This is important to know if this is a bug or if it is a compatibility issue.

If the problem persists, what steps should I follow to replicate the this issue?

Thank you.

June 18, 2017 at 10:21 am #1300419

thomasK-40

Hi,

my Code ist as simple as that:

$posts = get_posts(
[
'show_posts' => -1,
'post_type' => 'download',
'tax_query' => [[
'taxonomy' => 'download-area',
'field' => 'slug',
'terms' => 'publications'
]],
'posts_per_page' => -1,
]
);

and on both pages, it's looking for english downloads.

June 18, 2017 at 10:22 am #1300420

thomasK-40

i disabled all plugins beside tools and wpml (with tools, i created the cpt, tax etc.)

June 18, 2017 at 10:22 am #1300421

thomasK-40

i mean toolset types

June 18, 2017 at 10:24 am #1300422

thomasK-40

it just happens after updating from 4.7.5 to 4.8, with no plugin interference.

June 19, 2017 at 2:34 pm #1301141

Bruno
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi,

Thank you for contacting us.

I saw the problem you're reporting. Thank you for the code snippet. The problem is that the slug, when translated, will not return the correct result.

For example:

'terms' => 'publications'

Internally, if you have translated the slug to "publications-fr", the above filter will not work as expected. As a suggestion you can use term_id instead of the slug:

     'taxonomy' => 'download-area',
     'field' => 'term_id',
     'terms' => 123 // desired term ID

Following these steps, the list of posts is displayed correctly.

I'll contact 2nd tier support to ask about this. In the meantime, you can use term_id to be able to have WordPress updated.

Thank you.

July 5, 2017 at 1:40 pm #1312649

James

Hi Bruno, Thomas,

Just posting some extra info here as we have the same problem on our site since updating to WP 4.8.

The following code snippet used to work fine in all languages to return the ID of the translated custom taxonomy.

...
$partner_type = "oem";
$partner_type_term_data = get_term_by( 'slug', $partner_type, 'cz_partner_type' );
$partner_type_id = (int) $partner_type_term_data->term_id;		
...

Since updating to WordPress 4.8, get_term_by() only works if the translated slug is passed in.

It's quite possible that my original code was doing things badly - but it did used to work OK, and since updating to WP 4.8 something has changed.

James

July 14, 2017 at 6:54 am #1319347

Paul

Hi

We have the same problem. Exactly the same problem...

Since updating to WordPress 4.8, get_term_by() only works if the translated slug is passed in.

It's quite possible that my original code was doing things badly - but it did used to work OK, and since updating to WP 4.8 something has changed.

Is there a fix ! related thread https://wpml.org/forums/topic/translated-category/

This code als fails and now needs to have the translated category name in wp 4.8.

if($cat != ''){
        $query['tax_query'] = array(
            array(
                'taxonomy' => 'portfolio_category',
                'field' => 'slug',
                'terms' => explode(',', $cat)
            )
        );
    }

Best regards,
Paul

July 14, 2017 at 8:05 am #1319414

Paul

@bruno

I am sorry but the solution you provide is not the way to handle this problem.

"Internally, if you have translated the slug to "publications-fr", the above filter will not work as expected. As a suggestion you can use term_id instead of the slug:"

I dont understand why you are waiting on user feedback. The problem is more severe and not solved by calling by ids.

Many theme use slugnames when calling categories or when setting up a wpquery or using the get_term_by function.

The correct slugs/ids should return for the translated page(s).

The solution provided is not the way it should be and how it worked until wp 4.7.5

Even trying to get the id in the translated page of the original category slug does return 0. There is a big problem here.

Please provide a working fix.

July 18, 2017 at 10:39 am #1321779

James

This is the only clue I can find in the WP code reference:

https://developer.wordpress.org/reference/functions/get_terms/#changelog

get_terms();
Version 4.8.0 Introduced 'suppress_filter' parameter.

Even though our site is now working (via a dirty workaround), I'm keen to understand what is going on here so I can make sure we avoid problems in the future.

James

September 21, 2017 at 11:20 pm #1379842

Bruno
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi,

Sorry for the delay.

This will be fixed in version 3.8.2, which will be released soon. Unfortunately, I do not have a deadline when this is going to be released. This should not take too long, though.

Thank you.