Skip Navigation

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 0 replies, has 1 voice.

Last updated by alanT-11 3 months, 4 weeks ago.

Assisted by: Long Nguyen.

Author Posts
July 19, 2024 at 3:46 am #15975588

alanT-11

Background of the issue:
My Android APP is using REST API call from my blog post and it doesn't show the post after WPML translates. The APP is configured with Language name as directory. With all my properties post is normal but not the blog post. It shows this error on my debug.log: [19-Jul-2024 03:38:04 UTC] PHP Warning: Undefined variable $user_notification in /home/oykx1duor2bp/public_html/fozaz.com/wp-content/plugins/houzi-rest-api/admin/partials/houzi-rest-api-admin-notify.php on line 82 [19-Jul-2024 03:40:03 UTC] PHP Fatal error: Uncaught Error: Object of class WP_Term could not be converted to string in /home/oykx1duor2bp/public_html/fozaz.com/wp-content/plugins/sitepress-multilingual-cms/inc/taxonomy-term-translation/wpml-term-translation.class.php:133

Symptoms:
PHP Fatal error: Uncaught Error: Object of class WP_Term could not be converted to string in /home/oykx1duor2bp/public_html/fozaz.com/wp-content/plugins/sitepress-multilingual-cms/inc/taxonomy-term-translation/wpml-term-translation.class.php on line 133

Questions:
Why doesn't my blog post show after WPML translates it?
How can I fix the PHP Fatal error related to WP_Term in wpml-term-translation.class.php?

July 19, 2024 at 6:31 am #15976049

alanT-11

I have manage to debug and fixed the issued from /wp-content/plugins/sitepress-multilingual-cms/inc/taxonomy-term-translation/wpml-term-translation.class.php(199): WPML_Term_Translation->adjust_ttid_for_term_id()

LINE 196

From this
public function term_id_in( $term_id, $lang_code, $original_fallback = false ) {

return $this->adjust_term_id_for_ttid(
$this->element_id_in( (int) $this->adjust_ttid_for_term_id( $term_id ), $lang_code, $original_fallback )
);
}

To this

public function term_id_in( $term_id, $lang_code, $original_fallback = false ) {
// Ensure $term_id is an integer
if ( is_object( $term_id ) && $term_id instanceof WP_Term ) {
$term_id = $term_id->term_id;
}

return $this->adjust_term_id_for_ttid(
$this->element_id_in( (int) $term_id, $lang_code, $original_fallback )
);
}

Now is FIXED!!!