Support » Plugin: Polylang » Several languages for one post or category?

  • Resolved winnewoerp

    (@joschi81)


    Hi Chouby,

    I’m using your plugin on this site:
    http://www.nextistanbul.org

    I was wondering if there is a possibility to set several languages for one post or category? I need to do this, because posts in this site are not being translated and need to be visible in both languages.

    Or, instead of giving several languages to one post or category, is it possible to set the language manually in the template code? Telling WP using PHP at a certain point to always use the English translation from now on and later in the code switch back to the language given by Polylang?

    Thank for your help!

    joschi81

    http://wordpress.org/extend/plugins/polylang/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Chouby

    (@chouby)

    No it’s not possible. Because we need to display the site in only one language. If a post has two, which one to take ?

    What may be possible (I did not test) is to create a custom post type without activating the language and translation management. Polylang will not filter this content and will load the “preferred language” from cookie. This is what is done for media when unchecking “language and translation management for media” in Polylang settings.

    Thread Starter winnewoerp

    (@joschi81)

    Ok, thanks for your reply, good to know. But what about saying in the code that if the current language is “EN” (e.g.) it should nevertheless load the content of a post in “TR” (e.g.)?

    Something like:

    // switching from English to Turkish
    if($curlang->slug=='en') {
    $default_lang = 'en';
    set_query_lang('tr');
    // [...more code...]
    // switching back to English
    set_query_lang($default_lang);

    set_query_lang() would have to be defined then, of course.

    Regards
    joschi81

    Plugin Author Chouby

    (@chouby)

    Oh… With PHP code, it’s somewhat different. I believe that you can reach a great level of customization by integrating some Polylang functions in your theme or in a plugin.

    You can get the current language with pll_current_language() and the default language with pll_default_language(). You can query posts in the languages you want whatever the current language. For example:

    $posts = get_posts(array(
        'post_type' => 'post',
        'lang' => 'de,fr', // query German and French posts
        'showposts' => 5
    ));

    You can also use this ‘lang’ parameter in ‘get_terms’.
    More information is available in http://polylang.wordpress.com/documentation/documentation-for-developers/.

    Thread Starter winnewoerp

    (@joschi81)

    Thank you for your fast reply (as always!). I’ll do it like that.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Several languages for one post or category?’ is closed to new replies.