Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. // WPML Plugin - Get the ID of original Post
  2. global $sitepress; // Assuming the plugin is active
  3.  
  4. $original_post_id = apply_filters(
  5. 'wpml_object_id',
  6. get_the_id(),
  7. get_post_type(get_the_id()),
  8. false,
  9. $sitepress->get_default_language()
  10. );
  11.  
  12. echo '$original_post_id - ' . $original_post_id;
  13.  
  14. --------------------------
  15. // Get translated post ID
  16. -------------------------
  17. global $sitepress; // Assuming the plugin is active
  18. $element_obj = get_page_by_path( 'news' );
  19. $element_id = $element_obj->ID;
  20. $element_type = get_post_type($element_id);
  21.  
  22. ----------------------------------
  23. // Get term id of custom taxonomy
  24. ----------------------------------
  25. $translated_term_id = apply_filters( 'wpml_object_id', ORIGNAL_TERM_ID, 'TAXONOMY_NAME', false );
  26. $return_original_if_missing = true;
  27. $ulanguage_code = ICL_LANGUAGE_CODE;
  28.  
  29. $post_id = apply_filters( 'wpml_object_id', $element_id, $element_type, $return_original_if_missing, $ulanguage_code );
  30.  
  31. echo '$post_id - ' . $post_id;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement