WordPress.org

Ready to get started?Download WordPress

Forums

Ceceppa Multilingua
[resolved] get_current_lang() not working properly (7 posts)

  1. gustavo-clicknaranja
    Member
    Posted 1 year ago #

    Hi!

    I'm using this to get the current language:

    global $wpCeceppaML;
    $wpCeceppaML->get_current_lang();

    but it always returns the same! I have two languages, "en" (english) and "es" (spanish), and this function is always returning "es". I can change the language of the page, choosing it in the languages menu, or changing the url parameters (&lang=en), and the menu changes, and everything changes, but the function I am calling from a plugin php is always returning "es", never "en".

    Do you know why is this happening, and how could I solve it?

    Many thanks!

    http://wordpress.org/extend/plugins/ceceppa-multilingua/

  2. Alessandro Senese
    Member
    Plugin Author

    Posted 1 year ago #

    Try if with 1.0

  3. Alessandro Senese
    Member
    Plugin Author

    Posted 1 year ago #

    With 1.0 use this for get current language:

    cml_get_current_language();

    This function return a php object with this fields:

    *) id - id of language
    *) cml_default - 1 if it is the default language
    *) cml_flag - name of flag
    *) cml_language - name of the language
    *) cml_language_slug - slug of the language
    *) cml_locale - wordpress locale

  4. gustavo-clicknaranja
    Member
    Posted 1 year ago #

    Only with 1.0? I have installed 1.0.2 version...

    And I'm getting an error with cml_get_current_language();
    I call it from the theme header.php and I get this message:

    "Call to undefined function cml_get_current_language();"

  5. Alessandro Senese
    Member
    Plugin Author

    Posted 1 year ago #

    That function exists since version 1.0.0.

    You get "undefined function" because the plugin has not yet been loaded, but it is strange because I've added that function at the top of my "header.php" and works correctly....

    Let me know which theme you are using, so I test plugin with it...

  6. Alessandro Senese
    Member
    Plugin Author

    Posted 1 year ago #

    Have you solved the problem?

  7. gustavo-clicknaranja
    Member
    Posted 1 year ago #

    Thank you Alessandro, you are right, the function works correctly in other places but not there, for some reason the plugin was not loaded yet.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic