• Resolved KZeni

    (@kzeni)


    I ran into a site where they’re using Polylang for multilingual content, but they had a page where they didn’t want to have leave the language of the site the visitor’s using while still only having one set of content to manage. The default behavior would keep the language of the currently viewed page even though I was specifying the ID of the content (which is unique for each language). The fix was to make it so the shortcode could accept & appropriately handle the lang query parameter.

    I’ve submitted my solution as a pull request at: https://github.com/billerickson/display-posts-shortcode/pull/196

    This defaults to whatever get_locale() returns, but it also accepts lang=”” for the default language or having lang be whatever the appropriate locale should be.

    I’d love to see this officially implemented in the plugin for future use.

    Thanks for the great plugin,
    Kurt

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Bill Erickson

    (@billerickson)

    Thanks for the pull request! I’ll take a deeper look and test it when I’m working on the next release of the plugin.

    This parameter is only used by the Polylang plugin, correct? There is no “lang” parameter in WP_Query currently.

    Thread Starter KZeni

    (@kzeni)

    Sounds great! Thank you!

    It appears this is added by Polylang, yes. However, the use of “lang” as a WP_Query parameter might not be exclusive to Polylang (a moment spent looking at other plugins showed they might also take this into account). That being said, Polylang is one of the most widely used multilingual site plugins for WordPress (if not the most used plugin which alters WP_Query for serving separate translated content).

    Also, I made sure to leave “lang” as the parameter name as it directly affects “lang” in the WP_Query so there’s no confusion about what it is & isn’t doing.

    Thanks again!

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

The topic ‘Proposed Patch: Add language selection support to the shortcode & query.’ is closed to new replies.