Title: Detect language page in code
Last modified: October 18, 2017

---

# Detect language page in code

 *  Resolved [pipoulito](https://wordpress.org/support/users/pipoulito/)
 * (@pipoulito)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/detect-language-page-in-code/)
 * Hi,
 * In a function in functions.php i need to detect the language of the page , is
   there a function to do that please ?
 * thanks

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [ronhard](https://wordpress.org/support/users/ronhard/)
 * (@ronhard)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/detect-language-page-in-code/#post-9600666)
 * For me it’s not 100% clear if you want to get the current language (set by user
   or automatically set by polylang for that user) or if you want to get the language
   of a particular page?
 * For case 1) there is:
 *     ```
       pll_current_language
   
       Returns the current language
       Usage:
   
       1
       pll_current_language($value);
       ‘$value’ => (optional) either ‘name’ or ‘locale’ or ‘slug’, defaults to ‘slug’
       returns either the full name, or the WordPress locale (just as the WordPress core function ‘get_locale’ or the slug ( 2-letters code) of the current language.
       ```
   
 * For case 2) there is:
 *     ```
       pll_get_post_language
   
       gets the language of a post or page (or custom post type post)
       Usage:
   
       1
       pll_get_post_language($post_id, $field);
       ‘$post_id’ => (required) id of the post for which you want to get the language
       ‘$field’ => (optional) either ‘name’ or ‘locale’ or ‘slug’, defaults to ‘slug’
   
       returns either the full name, or the WordPress locale or the slug ( 2-letters code) of the post.
       ```
   
 * Both can be found here:
    [https://polylang.wordpress.com/documentation/documentation-for-developers/functions-reference/](https://polylang.wordpress.com/documentation/documentation-for-developers/functions-reference/)
    -  This reply was modified 8 years, 7 months ago by [ronhard](https://wordpress.org/support/users/ronhard/).
 *  Thread Starter [pipoulito](https://wordpress.org/support/users/pipoulito/)
 * (@pipoulito)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/detect-language-page-in-code/#post-9600703)
 * yes that’s it !! merci beaucoup 😉 !!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Detect language page in code’ 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/)

 * 2 replies
 * 2 participants
 * Last reply from: [pipoulito](https://wordpress.org/support/users/pipoulito/)
 * Last activity: [8 years, 7 months ago](https://wordpress.org/support/topic/detect-language-page-in-code/#post-9600703)
 * Status: resolved