• Hi,
    I´ve recently activated Polylang in my wordpress installation. All is working fine, however since I am integrating two different systems in my website, in some occasions I need to have the language set from an external variable.

    How can I achieve that?
    I need this mostly when loading the widgets, because I need to show the list of recent post and so on accordingly to my external variable.

    I have been looking throught the Polylang code, but I´m not yet sure on how properly do that.

    Thank you, kind regards.

    https://wordpress.org/plugins/polylang/

Viewing 3 replies - 1 through 3 (of 3 total)
  • dina_fire

    (@dina_fire)

    After poking around in the database of my site, I figured out how Polylang stores its language information – as taxonomy terms, in the wp_terms table. It’s not a perfect solution for a number of reasons, but you could just check what the ID of your desired language is and use wp_set_object_terms() to add the term to your posts.

    Ideally you (and I) would use a function native to Polylang to avoid hunting in the database for the term ID, not to mention to avoid having to implement the fix differently on different websites, but I unfortunately don’t know of such a function.

    Hope this helps, as far as it can.

    Plugin Author Chouby

    (@chouby)

    dina_fire

    (@dina_fire)

    Perfect, thank you.

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

The topic ‘Programmatically set language?’ is closed to new replies.