WPML Translated Term

Actually there is already in their API something for this: icl_object_id(ID, custom_taxonomy_name, return_original_if_missing,language_code) Works like a charm. More read on this : Language Dependent IDs

WPML Translating a term/taxonomy programmatically

Ok I found the solution. Actually taxonomy name on icl_translation table is stored with prefix called “tax_” which means taxonomy. The above code would work like this: $trid = $sitepress->get_element_trid($englist_term_id, “tax_taxonomy_name”); $sitepress->set_element_language_details($new_term_id, “tax_taxonomy_name”, $trid, $lang_code, $sitepress->get_default_language()); The difference is tax_ prefix. Cheers!

Cannot use object of type WP_Error as array

Well, it’s pretty clear, why this problem occurs. Let’s look at wp_insert_term documentation: Return Values (array|WP_Error) The Term ID and Term Taxonomy ID. (Example: array(‘term_id’=>12,’term_taxonomy_id’=>34)) As you can see, on success this function returns array. But… If any error occurs, it will return an object of WP_Error type. So… This Fatal Error occurs, because wp_insert_term … Read more

Created pages not showing up in ‘All Pages’ list

The problem was actually the pages having “no language” and WPML seems to hate this. So I just deleted all those pages and re-inserted them with the proper WPML language attributes: // (…) // Create the page $customPage[‘id’] = wp_insert_post( $pageParams ); // Check if WPML parameters are needed if (has_action(‘wpml_set_element_language_details’)) { // Set WPML … Read more

How can override a add_filter of a plugin?

Filters come with a priority parameter, the default is 10, so to override a function you need to increase the priority: add_filter( ‘wcml_switch_currency_exception’, ‘cart_switching_currency’, 99, 4 ); add_filter( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 ) More info in the add_filter Update: If removing a filter is not working you … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)