• Resolved riyazmuhammad

    (@riyazmuhammad)


    Hi,

    Polylang plugin is superb. I am very happy to use it. I had setup everything and working fine on my local setup. Then I implemented on my site https://www.esimsar.com/blog/ . My default lang is “Arabic” and other one is English. Posts are switching when I click language switcher. But when I check current language it is always showing “Arabic”.

    $currentlang = get_bloginfo('language');
    <?php if($currentlang=="ar"): ?> dir="rtl" <?php else: ?> dir="ltr" <?php endif; ?>

    This code always showing arabic only even I switch to English.
    <html <?php language_attributes(); ?>>.

    I have tried functions pll_the_languages()
    and get_locale(). But still current language is same (arabic).

    I am using this code for language swicther:
    <?php pll_the_languages(array('dropdown'=>0, 'hide_current'=>0, 'hide_if_no_translation'=>1, 'show_names'=>1)); ?>
    This shows both languages.

    Can anyone please help me on this. Thanks in advance,

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • anonymized-13603639

    (@anonymized-13603639)

    Don’t know where you use your code but try using pll_current_language. This function returns the current language.

    https://polylang.wordpress.com/documentation/documentation-for-developers/functions-reference/

    Thread Starter riyazmuhammad

    (@riyazmuhammad)

    Hi @lachender_engel,

    Thanks for the reply.

    I have added function pll_current_language for checking the current language ( You can see that in top right corner of the page ). but it is always showing my default language( Arabic).
    when I click language switcher to english, the main content and url is only changing.
    I wrote all other like header, logo, footer and sidebar based on current language. but those are always in arabic even if I am clicking english version.
    Language switcher is not working properly for some reason.

    Let me know please know anything you can help me on this.

    Thank you,

    anonymized-13603639

    (@anonymized-13603639)

    Where do you use this function? In the header.php or the function.php?

    Thread Starter riyazmuhammad

    (@riyazmuhammad)

    Thank you lachender_engel.

    Issue fixed now. The issue was happened because of my URL is redirected from subdomain to subdirectory. So I can only choose the option “The language is set from content” on poly lang settings page. This is the only option working in my case. this option will not effect on my current .htaccess rules and permalinks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Language not switching correctly.’ is closed to new replies.