I am using a WP 6.0 with Polylang plugin. So there are english pages and german pages. I want to show or hide some block depending on a language of the page. I know about such built-in functions in WP like is_archive() or is_singular() or is_search() or is_404().
How can a function to check the language of a post or a page can look? I see that in the database in "postmeta" table there is a column "meta_key" that can content "_locale" value and a column "meta_value", that can be, im my case, "en_US" or "de_DE". How can i prepare something like is_en() or is_de() or lang_is() function?
P.S.: Maybe also table to perform this checking is not "postmeta", but "term_taxonomy", where we have columns "taxonomy" and "description"...
CodePudding user response:
The get_locale()
function returns the language of the currently viewed page:
https://developer.wordpress.org/reference/functions/get_locale/
like 'en_US' if you are on an english page.