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
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
woocommerce_checkout_fields filter allows you to alter the order of fields displayed in the checkout page, you can add a condition in the callback to check for the country or language.
You should create another Contact Form for any different language. You include the form with shortcode, so it’s pretty easy to duplicate a form, translate it to given language and then modify the shortcode.
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!
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
I have developed pages in that manner and if you are using WordPress functions and follow WP Codex it is same situation as if you developed custom page template. Just follow I18n for WordPress Developers and you will be fine.
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
I’ve done it with this bit of code: global $wpdb; $posts = get_posts(array(‘post_type’=>’…’, ‘posts_per_page’=>-1)); foreach($posts as $post) { $wpdb->update(‘wp_icl_translations’, array(‘language_code’=>’es’), array(‘element_id’=> $post->ID)); }
I’ve found what was going on, so I’m going to answer it for future reference, as it’s a common issue without clear solution. TL;DR: If the WPML language which’s not redirecting has a country code (eg. en-US instead of en) then you probably have the same bug. Jump to section “How to fix it”. The … Read more
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