Last active
July 26, 2019 06:25
-
-
Save developer-anuragsingh/a8b054c0f42a529b600e76d6737c6882 to your computer and use it in GitHub Desktop.
// WPML Plugin - Get the ID of original Post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // WPML Plugin - Get the ID of original Post | |
| global $sitepress; // Assuming the plugin is active | |
| $original_post_id = apply_filters( | |
| 'wpml_object_id', | |
| get_the_id(), | |
| get_post_type(get_the_id()), | |
| false, | |
| $sitepress->get_default_language() | |
| ); | |
| echo '$original_post_id - ' . $original_post_id; | |
| -------------------------- | |
| // Get translated post ID | |
| ------------------------- | |
| global $sitepress; // Assuming the plugin is active | |
| $element_obj = get_page_by_path( 'page' ); | |
| $element_id = $element_obj->ID; | |
| $element_type = get_post_type($element_id); | |
| $translated_element_id = icl_object_id($element_id, 'page', false, ICL_LANGUAGE_CODE); // Translated post ID | |
| ---------------------------------- | |
| // Get term id of custom taxonomy | |
| ---------------------------------- | |
| $translated_term_id = apply_filters( 'wpml_object_id', ORIGNAL_TERM_ID, 'TAXONOMY_NAME', false ); | |
| $return_original_if_missing = true; | |
| $ulanguage_code = ICL_LANGUAGE_CODE; | |
| $post_id = apply_filters( 'wpml_object_id', $element_id, $element_type, $return_original_if_missing, $ulanguage_code ); | |
| echo '$post_id - ' . $post_id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment