Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2019
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.86 KB | None | 0 0
  1. // Show linked WPML posts in a loog
  2. function wpml_post_languages_in_loop() {
  3.     $post_trid = apply_filters('wpml_element_trid', NULL, get_the_ID(), 'post_' . get_post_type());
  4.     $languages = apply_filters( 'wpml_active_languages', NULL, 'skip_missing=0&orderby=code' );
  5.     if (empty($post_trid))
  6.         return;
  7.     $translation = apply_filters('wpml_get_element_translations', NULL, $post_trid, 'post_' . get_post_type());
  8.     if (1 < count($translation)) {
  9.         echo __('Document also available in: ');
  10.         foreach ($translation as $l) {
  11.             if ($l->element_id != get_the_ID()) {
  12.                 $langs[] = '<a href="' . apply_filters('wpml_permalink', ( get_permalink($l->element_id)), $l->language_code) . '">' . $languages[$l->language_code]['translated_name'] . '</a>';
  13.             }
  14.         }
  15.  
  16.         echo join('  ', $langs);
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement