Title: pll_get_post() function is not working
Last modified: August 30, 2016

---

# pll_get_post() function is not working

 *  Resolved [ashpriom](https://wordpress.org/support/users/ashpriom/)
 * (@ashpriom)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/pll_get_post-function-is-not-working/)
 * Hi,
 * I used the following to get the ID of the linked post:
 * `if(function_exists('pll_get_post')){ echo pll_get_post($postID,$currentLang);}`
 * Concrete scenario: The $postID is ’46’ (French version of the post) and $currentLang
   is ‘fr’. So it should return the $postID of the English version of this French
   post right? Which is 11026. But I am getting $postID of the same page, 46.
 * My objective is to get some custom field values from the English post so that
   users don’t need put the same information twice. This is why I need the linked
   post ID to fetch data. May be I’m missing something obvious. Can you help please?
 * [https://wordpress.org/plugins/polylang/](https://wordpress.org/plugins/polylang/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [ashpriom](https://wordpress.org/support/users/ashpriom/)
 * (@ashpriom)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/pll_get_post-function-is-not-working/#post-6402130)
 * Alright, I figured it out. Some obvious that confused me.
 * Say for instance, if you are on a French post, but you want to grab the ID of
   its English counterpart, do this:
 *     ```
       $postID = get_the_ID();
       if (function_exists('pll_current_language')) {
       $currentLang = pll_current_language('slug');
       }
       $translationID = pll_get_post($postID,'en');
       ```
   
 * First detect the current post ID and its language. Okay.
    Then apply the `pll_get_post(
   $postID, "language code")`. The “en” here is the language code for the target
   post ID. For instance if you want German counterpart’s ID, it would be ‘de’, 
   and vice versa.

Viewing 1 replies (of 1 total)

The topic ‘pll_get_post() function is not working’ is closed to new replies.

 * ![](https://ps.w.org/polylang/assets/icon-256x256.png?rev=3433336)
 * [Polylang](https://wordpress.org/plugins/polylang/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/polylang/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/polylang/)
 * [Active Topics](https://wordpress.org/support/plugin/polylang/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/polylang/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/polylang/reviews/)

## Tags

 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)

 * 1 reply
 * 1 participant
 * Last reply from: [ashpriom](https://wordpress.org/support/users/ashpriom/)
 * Last activity: [10 years, 9 months ago](https://wordpress.org/support/topic/pll_get_post-function-is-not-working/#post-6402130)
 * Status: resolved