Tag: get_results

  • WPML:Get posts also available in other languages

    WPML:Get posts also available in other languages

    文章页面里,在文章的底部显示该篇文章对应的翻译的语种(国旗)和标题。 暂时没有发现有现成的函数或 API 接口。但是从WPML 的表里面不难看出他们的关系,通过一句SQL即可找出当前文章对应文章的ID, 如下: function _post_foot_languages(){ global $post, $wpdb, $sitepress; $active_languages = $sitepress->get_active_languages(); unset($active_languages[ICL_LANGUAGE_CODE]); //print_r(array_keys($active_languages)); $source_language_code = “”; if(ICL_LANGUAGE_CODE != $sitepress->get_default_language()) $source_language_code = ” and source_language_code = ‘”.$sitepress->get_default_language().”‘”; $query =” SELECT * FROM {$wpdb->prefix}icl_translations WHERE trid = ( SELECT trid FROM {$wpdb->prefix}icl_translations WHERE element_id = {$post->ID}{$source_language_code}) AND language_code in (‘”.join(‘\’,\”,array_keys($active_languages)).”‘)”; //AND language_code !=…