wpml compatibility
-
in this thread:
https://wordpress.org/support/topic/not-compatible-with-wpml-1?replies=3I used this hack, but using wpml everytime I edit a taxonomy it writes correctly the rules for the current taxonomy language, but brakes all the others.
It’s a problem due to the current admin language selected, this is my corrected code that finally works, getting all terms for all languages and not only for the selected admin language.function rtbs_get_all_terms( $taxonomy = 'category', $args = array( 'hide_empty' => false ) ) { global $sitepress; $sitepress->switch_lang("all"); //set all languages $terms = get_terms( $taxonomy,$args ); //get terms for all languages if ( function_exists( 'icl_get_languages' ) ) { $languages = icl_get_languages(); if ( 1 < count( $languages ) ) { foreach ( $languages as $l ) { $language_code = $l['language_code']; foreach ( $terms as $t ) { $id = icl_object_id( $t->term_id, $taxonomy, false, $language_code ); if ( null !== $id ) $ids[] = $id; } } if ( is_array( $ids ) && 1 <= count( $ids ) ) { global $wpdb; $ids = implode( ',', $ids ); $results = $wpdb->get_results( " SELECT * FROM $wpdb->terms WHERE term_id IN ($ids) " ); $terms = array_merge( $terms, $results ); } } } return $terms; }
The topic ‘wpml compatibility’ is closed to new replies.