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

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.


This topic contains 6 replies, has 2 voices.

Last updated by Nohemi 7 months, 1 week ago.

Assigned support staff: Yvette.

Author Posts
June 12, 2019 at 11:26 am


I am trying to: go to url hidden link

I expected to see: a 404 error

Instead, I got: a 500 error : Object of class WP_Error could not be converted to string in wp-includes/pluggable.php on line 1282

I have found two topics with the same problem :

Apparently, this is due to the new function

	private function maybe_redirect_to_translated_taxonomy( $q, $current_lang ) {
		if ( ! $q->is_main_query() ) {
			return $q;

		foreach ( $this->get_query_taxonomy_term_slugs( $q ) as $slug => $taxonomy ) {
			$translated_slugs = $this->translate_term_values( array( $slug ), 'slugs', $taxonomy, $current_lang );

			if ( $translated_slugs && $slug !== $translated_slugs[0] ) {
				$translated_term = get_term_by(

				$new_url = get_term_link( $translated_term, $taxonomy );

				/** @var WPML_WP_API */
				global $wpml_wp_api;
				$wpml_wp_api->wp_safe_redirect( $new_url );

				return null;

		return $q;

To check if there is a translated taxonomy you do

$slug !== $translated_slugs[0]

except that $slug is an integer (123) and $translated_slugs[0] is a string "123".
So the comparison returns true even if it is the same slug.
=> get_term_by returns false and so on until the 500 error.

June 12, 2019 at 3:49 pm #4005897


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

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


I tried this out on my local server and was unable to reproduce this error.
I also created a sandbox site here:
hidden link

Again, I am unable to reproduce the error.

Could you tell me more about your server?
Are you able to reproduce this problem on the sandbox site?

June 13, 2019 at 8:14 am #4010431


Indeed, i can not reproduce the problem on the sandbox but i have reinstalled WordPress on my demo site. Just configure permalinks and WPML (only click on next buttons) and i can reproduce the bug.

I have already give you WP admin access. I can send you FTP credentials if you want.

June 13, 2019 at 10:34 am #4011981


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

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

Yes - I did connect to your site and see the issue.
However, I believe this might be related to your server setup since it is not reproducible either on a sandbox site --OR-- a local server

What kind of server are you using? e.g. are you using virtual hosts, for example?

June 13, 2019 at 11:42 am #4012443


Okay, on the sandbox you installed a version not yet released (4.2.7). On my website i installed the last version available (4.2.6)

On version 4.2.7 you have fixed the issue... (exactly where i said, in maybe_redirect_to_translated_taxonomy...)

I installed 4.2.6 version on your sandbox and tada : hidden link

June 13, 2019 at 4:23 pm #4015613


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

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

OK!! So we have an answer. =)

Curiously - I still cannot replicate this on my local server and it´s got 4.2.6. installed.
The sandbox site uses virtual I still think this has something to do with it.

In any case, it seems the resolution is delievered in the 4.2.7 release.
Are you ok with closing this ticket now?

June 14, 2019 at 7:48 am #4019027


I can reproduce the bug totally : install 4.2.6 version AND set permalinks on custom structure : /%category%/%postname%/ (which is a standard setting).

If it is fixed on 4.2.7 version i close the ticket.