Can not get the current language to appear in the widget
Hi I have a problem with a couple of widgets on my Wordpress site. It always takes the first language (english ) instead of the correct language that the page is on at that moment.
Here is my code from one of the widgets:
<?php
if ( is_active_sidebar('logostrip') ) {
$widgets = wp_get_sidebars_widgets(true, true, 'logostrip', true);
$logoWidget = $widgets['logostrip'];
$langs = count(pll_languages_list());
$currentLang = pll_current_language();
for ($i=0; $i < $langs; $i++) {
if ( $logoWidget[$i] ) {
$logoId = $logoWidget[$i];
$i = $langs;
}
}
$title = get_field('header', 'widget_' . $logoId);
$title = preg_replace(array('/[/', '/]/'), array('<', '>'), $title);
$logos = get_field('client_logos', 'widget_' . $logoId);
$maxItems = 6;
?>
Could anybody help me with this? I have already implemented this so that it would take the current language but nothing happens.
$currentLang = ppl_current_language();
Thank you!
php wordpress
|
show 1 more comment
Hi I have a problem with a couple of widgets on my Wordpress site. It always takes the first language (english ) instead of the correct language that the page is on at that moment.
Here is my code from one of the widgets:
<?php
if ( is_active_sidebar('logostrip') ) {
$widgets = wp_get_sidebars_widgets(true, true, 'logostrip', true);
$logoWidget = $widgets['logostrip'];
$langs = count(pll_languages_list());
$currentLang = pll_current_language();
for ($i=0; $i < $langs; $i++) {
if ( $logoWidget[$i] ) {
$logoId = $logoWidget[$i];
$i = $langs;
}
}
$title = get_field('header', 'widget_' . $logoId);
$title = preg_replace(array('/[/', '/]/'), array('<', '>'), $title);
$logos = get_field('client_logos', 'widget_' . $logoId);
$maxItems = 6;
?>
Could anybody help me with this? I have already implemented this so that it would take the current language but nothing happens.
$currentLang = ppl_current_language();
Thank you!
php wordpress
Where are you using the$currentLang
variable?
– EM-Creations
Nov 21 '18 at 9:51
1
seems like you are not checking if$currentLang
matches anything.
– Stender
Nov 21 '18 at 9:52
also -$i = $langs;
makes sure, that the first time you hit your forloop, you update the$i
so that you won't hit it again - making sure that you only get the first instance in the loop - that shit needs be go son!
– Stender
Nov 21 '18 at 9:54
or should only happen, if you have found the correct logo, using$currentLang
– Stender
Nov 21 '18 at 9:55
1
Did you try to print_r() the first four variables? That could be helpful
– Lis
Nov 21 '18 at 9:57
|
show 1 more comment
Hi I have a problem with a couple of widgets on my Wordpress site. It always takes the first language (english ) instead of the correct language that the page is on at that moment.
Here is my code from one of the widgets:
<?php
if ( is_active_sidebar('logostrip') ) {
$widgets = wp_get_sidebars_widgets(true, true, 'logostrip', true);
$logoWidget = $widgets['logostrip'];
$langs = count(pll_languages_list());
$currentLang = pll_current_language();
for ($i=0; $i < $langs; $i++) {
if ( $logoWidget[$i] ) {
$logoId = $logoWidget[$i];
$i = $langs;
}
}
$title = get_field('header', 'widget_' . $logoId);
$title = preg_replace(array('/[/', '/]/'), array('<', '>'), $title);
$logos = get_field('client_logos', 'widget_' . $logoId);
$maxItems = 6;
?>
Could anybody help me with this? I have already implemented this so that it would take the current language but nothing happens.
$currentLang = ppl_current_language();
Thank you!
php wordpress
Hi I have a problem with a couple of widgets on my Wordpress site. It always takes the first language (english ) instead of the correct language that the page is on at that moment.
Here is my code from one of the widgets:
<?php
if ( is_active_sidebar('logostrip') ) {
$widgets = wp_get_sidebars_widgets(true, true, 'logostrip', true);
$logoWidget = $widgets['logostrip'];
$langs = count(pll_languages_list());
$currentLang = pll_current_language();
for ($i=0; $i < $langs; $i++) {
if ( $logoWidget[$i] ) {
$logoId = $logoWidget[$i];
$i = $langs;
}
}
$title = get_field('header', 'widget_' . $logoId);
$title = preg_replace(array('/[/', '/]/'), array('<', '>'), $title);
$logos = get_field('client_logos', 'widget_' . $logoId);
$maxItems = 6;
?>
Could anybody help me with this? I have already implemented this so that it would take the current language but nothing happens.
$currentLang = ppl_current_language();
Thank you!
php wordpress
php wordpress
asked Nov 21 '18 at 9:49
noah fnoah f
74
74
Where are you using the$currentLang
variable?
– EM-Creations
Nov 21 '18 at 9:51
1
seems like you are not checking if$currentLang
matches anything.
– Stender
Nov 21 '18 at 9:52
also -$i = $langs;
makes sure, that the first time you hit your forloop, you update the$i
so that you won't hit it again - making sure that you only get the first instance in the loop - that shit needs be go son!
– Stender
Nov 21 '18 at 9:54
or should only happen, if you have found the correct logo, using$currentLang
– Stender
Nov 21 '18 at 9:55
1
Did you try to print_r() the first four variables? That could be helpful
– Lis
Nov 21 '18 at 9:57
|
show 1 more comment
Where are you using the$currentLang
variable?
– EM-Creations
Nov 21 '18 at 9:51
1
seems like you are not checking if$currentLang
matches anything.
– Stender
Nov 21 '18 at 9:52
also -$i = $langs;
makes sure, that the first time you hit your forloop, you update the$i
so that you won't hit it again - making sure that you only get the first instance in the loop - that shit needs be go son!
– Stender
Nov 21 '18 at 9:54
or should only happen, if you have found the correct logo, using$currentLang
– Stender
Nov 21 '18 at 9:55
1
Did you try to print_r() the first four variables? That could be helpful
– Lis
Nov 21 '18 at 9:57
Where are you using the
$currentLang
variable?– EM-Creations
Nov 21 '18 at 9:51
Where are you using the
$currentLang
variable?– EM-Creations
Nov 21 '18 at 9:51
1
1
seems like you are not checking if
$currentLang
matches anything.– Stender
Nov 21 '18 at 9:52
seems like you are not checking if
$currentLang
matches anything.– Stender
Nov 21 '18 at 9:52
also -
$i = $langs;
makes sure, that the first time you hit your forloop, you update the $i
so that you won't hit it again - making sure that you only get the first instance in the loop - that shit needs be go son!– Stender
Nov 21 '18 at 9:54
also -
$i = $langs;
makes sure, that the first time you hit your forloop, you update the $i
so that you won't hit it again - making sure that you only get the first instance in the loop - that shit needs be go son!– Stender
Nov 21 '18 at 9:54
or should only happen, if you have found the correct logo, using
$currentLang
– Stender
Nov 21 '18 at 9:55
or should only happen, if you have found the correct logo, using
$currentLang
– Stender
Nov 21 '18 at 9:55
1
1
Did you try to print_r() the first four variables? That could be helpful
– Lis
Nov 21 '18 at 9:57
Did you try to print_r() the first four variables? That could be helpful
– Lis
Nov 21 '18 at 9:57
|
show 1 more comment
2 Answers
2
active
oldest
votes
I would suggest you to prefer using the get_locale()
function instead.
Anyway, what do you want to achieve ?
Because with Polylang :
- widgets are localized, so each language has his own
- theme options can be localized too with the following plugin, which could help you having different values for a same option depending on the current language
display the available language flags with PLL
Thanks! I would like to change the language of the text in the widget when the page itself is changed to a different language.
– noah f
Nov 21 '18 at 10:04
@noahf Do you mean the i18n of labels or the value from the widget itself ?
– Maxime Culea
Nov 21 '18 at 10:28
I mean the value form the widget itself. @MaximeCulea
– noah f
Nov 21 '18 at 10:35
@noahf then two solutions as mentionned : * theme options can be localized, which help you achieve different values for a same option depending on the current language * widgets are localized, so each language has his own. This means don't try to handle yourself, getting the widget values is automatic
– Maxime Culea
Nov 21 '18 at 14:54
add a comment |
Instead of pll_current_language(); please use get_option('WPLANG') to get the current language. Please copy and paste the code
<?php
if ( is_active_sidebar('logostrip') ) {
$widgets = wp_get_sidebars_widgets(true, true, 'logostrip', true);
$logoWidget = $widgets['logostrip'];
$langs = count(pll_languages_list());
$currentLang = get_option('WPLANG');
for ($i=0; $i < $langs; $i++) {
if ( $logoWidget[$i] ) {
$logoId = $logoWidget[$i];
$i = $langs;
}
}
$title = get_field('header', 'widget_' . $logoId);
$title = preg_replace(array('/[/', '/]/'), array('<', '>'), $title);
$logos = get_field('client_logos', 'widget_' . $logoId);
$maxItems = 6;
?>
Hope this work you.
Still not using$currentLang
for anything.
– Stender
Nov 21 '18 at 9:56
I have seen that, not getting data is one of the reason to not use. So I explained where the code has been changed. Hope he can undertsand it, otherwise I will explain it to him.
– Tristup
Nov 21 '18 at 10:00
@Stender What would you suggest using then?
– noah f
Nov 21 '18 at 10:00
@noahf, he is actually saying the the variable $currentLang has not been used on your code, so how it can be seen that the language is not fethced. Better you can print it once to check whether the actual langugae is showing or not
– Tristup
Nov 21 '18 at 10:02
1
@Tristup is right - What i am saying is, that you need to implement$currentLang
in your conditions for finding the correct logo. right now, you are just checking, if the first language you hit, exists in your$logoWidget
and then exit your loop - which is where your mistake is.
– Stender
Nov 21 '18 at 10:08
|
show 3 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53409285%2fcan-not-get-the-current-language-to-appear-in-the-widget%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I would suggest you to prefer using the get_locale()
function instead.
Anyway, what do you want to achieve ?
Because with Polylang :
- widgets are localized, so each language has his own
- theme options can be localized too with the following plugin, which could help you having different values for a same option depending on the current language
display the available language flags with PLL
Thanks! I would like to change the language of the text in the widget when the page itself is changed to a different language.
– noah f
Nov 21 '18 at 10:04
@noahf Do you mean the i18n of labels or the value from the widget itself ?
– Maxime Culea
Nov 21 '18 at 10:28
I mean the value form the widget itself. @MaximeCulea
– noah f
Nov 21 '18 at 10:35
@noahf then two solutions as mentionned : * theme options can be localized, which help you achieve different values for a same option depending on the current language * widgets are localized, so each language has his own. This means don't try to handle yourself, getting the widget values is automatic
– Maxime Culea
Nov 21 '18 at 14:54
add a comment |
I would suggest you to prefer using the get_locale()
function instead.
Anyway, what do you want to achieve ?
Because with Polylang :
- widgets are localized, so each language has his own
- theme options can be localized too with the following plugin, which could help you having different values for a same option depending on the current language
display the available language flags with PLL
Thanks! I would like to change the language of the text in the widget when the page itself is changed to a different language.
– noah f
Nov 21 '18 at 10:04
@noahf Do you mean the i18n of labels or the value from the widget itself ?
– Maxime Culea
Nov 21 '18 at 10:28
I mean the value form the widget itself. @MaximeCulea
– noah f
Nov 21 '18 at 10:35
@noahf then two solutions as mentionned : * theme options can be localized, which help you achieve different values for a same option depending on the current language * widgets are localized, so each language has his own. This means don't try to handle yourself, getting the widget values is automatic
– Maxime Culea
Nov 21 '18 at 14:54
add a comment |
I would suggest you to prefer using the get_locale()
function instead.
Anyway, what do you want to achieve ?
Because with Polylang :
- widgets are localized, so each language has his own
- theme options can be localized too with the following plugin, which could help you having different values for a same option depending on the current language
display the available language flags with PLL
I would suggest you to prefer using the get_locale()
function instead.
Anyway, what do you want to achieve ?
Because with Polylang :
- widgets are localized, so each language has his own
- theme options can be localized too with the following plugin, which could help you having different values for a same option depending on the current language
display the available language flags with PLL
answered Nov 21 '18 at 10:02
Maxime CuleaMaxime Culea
694
694
Thanks! I would like to change the language of the text in the widget when the page itself is changed to a different language.
– noah f
Nov 21 '18 at 10:04
@noahf Do you mean the i18n of labels or the value from the widget itself ?
– Maxime Culea
Nov 21 '18 at 10:28
I mean the value form the widget itself. @MaximeCulea
– noah f
Nov 21 '18 at 10:35
@noahf then two solutions as mentionned : * theme options can be localized, which help you achieve different values for a same option depending on the current language * widgets are localized, so each language has his own. This means don't try to handle yourself, getting the widget values is automatic
– Maxime Culea
Nov 21 '18 at 14:54
add a comment |
Thanks! I would like to change the language of the text in the widget when the page itself is changed to a different language.
– noah f
Nov 21 '18 at 10:04
@noahf Do you mean the i18n of labels or the value from the widget itself ?
– Maxime Culea
Nov 21 '18 at 10:28
I mean the value form the widget itself. @MaximeCulea
– noah f
Nov 21 '18 at 10:35
@noahf then two solutions as mentionned : * theme options can be localized, which help you achieve different values for a same option depending on the current language * widgets are localized, so each language has his own. This means don't try to handle yourself, getting the widget values is automatic
– Maxime Culea
Nov 21 '18 at 14:54
Thanks! I would like to change the language of the text in the widget when the page itself is changed to a different language.
– noah f
Nov 21 '18 at 10:04
Thanks! I would like to change the language of the text in the widget when the page itself is changed to a different language.
– noah f
Nov 21 '18 at 10:04
@noahf Do you mean the i18n of labels or the value from the widget itself ?
– Maxime Culea
Nov 21 '18 at 10:28
@noahf Do you mean the i18n of labels or the value from the widget itself ?
– Maxime Culea
Nov 21 '18 at 10:28
I mean the value form the widget itself. @MaximeCulea
– noah f
Nov 21 '18 at 10:35
I mean the value form the widget itself. @MaximeCulea
– noah f
Nov 21 '18 at 10:35
@noahf then two solutions as mentionned : * theme options can be localized, which help you achieve different values for a same option depending on the current language * widgets are localized, so each language has his own. This means don't try to handle yourself, getting the widget values is automatic
– Maxime Culea
Nov 21 '18 at 14:54
@noahf then two solutions as mentionned : * theme options can be localized, which help you achieve different values for a same option depending on the current language * widgets are localized, so each language has his own. This means don't try to handle yourself, getting the widget values is automatic
– Maxime Culea
Nov 21 '18 at 14:54
add a comment |
Instead of pll_current_language(); please use get_option('WPLANG') to get the current language. Please copy and paste the code
<?php
if ( is_active_sidebar('logostrip') ) {
$widgets = wp_get_sidebars_widgets(true, true, 'logostrip', true);
$logoWidget = $widgets['logostrip'];
$langs = count(pll_languages_list());
$currentLang = get_option('WPLANG');
for ($i=0; $i < $langs; $i++) {
if ( $logoWidget[$i] ) {
$logoId = $logoWidget[$i];
$i = $langs;
}
}
$title = get_field('header', 'widget_' . $logoId);
$title = preg_replace(array('/[/', '/]/'), array('<', '>'), $title);
$logos = get_field('client_logos', 'widget_' . $logoId);
$maxItems = 6;
?>
Hope this work you.
Still not using$currentLang
for anything.
– Stender
Nov 21 '18 at 9:56
I have seen that, not getting data is one of the reason to not use. So I explained where the code has been changed. Hope he can undertsand it, otherwise I will explain it to him.
– Tristup
Nov 21 '18 at 10:00
@Stender What would you suggest using then?
– noah f
Nov 21 '18 at 10:00
@noahf, he is actually saying the the variable $currentLang has not been used on your code, so how it can be seen that the language is not fethced. Better you can print it once to check whether the actual langugae is showing or not
– Tristup
Nov 21 '18 at 10:02
1
@Tristup is right - What i am saying is, that you need to implement$currentLang
in your conditions for finding the correct logo. right now, you are just checking, if the first language you hit, exists in your$logoWidget
and then exit your loop - which is where your mistake is.
– Stender
Nov 21 '18 at 10:08
|
show 3 more comments
Instead of pll_current_language(); please use get_option('WPLANG') to get the current language. Please copy and paste the code
<?php
if ( is_active_sidebar('logostrip') ) {
$widgets = wp_get_sidebars_widgets(true, true, 'logostrip', true);
$logoWidget = $widgets['logostrip'];
$langs = count(pll_languages_list());
$currentLang = get_option('WPLANG');
for ($i=0; $i < $langs; $i++) {
if ( $logoWidget[$i] ) {
$logoId = $logoWidget[$i];
$i = $langs;
}
}
$title = get_field('header', 'widget_' . $logoId);
$title = preg_replace(array('/[/', '/]/'), array('<', '>'), $title);
$logos = get_field('client_logos', 'widget_' . $logoId);
$maxItems = 6;
?>
Hope this work you.
Still not using$currentLang
for anything.
– Stender
Nov 21 '18 at 9:56
I have seen that, not getting data is one of the reason to not use. So I explained where the code has been changed. Hope he can undertsand it, otherwise I will explain it to him.
– Tristup
Nov 21 '18 at 10:00
@Stender What would you suggest using then?
– noah f
Nov 21 '18 at 10:00
@noahf, he is actually saying the the variable $currentLang has not been used on your code, so how it can be seen that the language is not fethced. Better you can print it once to check whether the actual langugae is showing or not
– Tristup
Nov 21 '18 at 10:02
1
@Tristup is right - What i am saying is, that you need to implement$currentLang
in your conditions for finding the correct logo. right now, you are just checking, if the first language you hit, exists in your$logoWidget
and then exit your loop - which is where your mistake is.
– Stender
Nov 21 '18 at 10:08
|
show 3 more comments
Instead of pll_current_language(); please use get_option('WPLANG') to get the current language. Please copy and paste the code
<?php
if ( is_active_sidebar('logostrip') ) {
$widgets = wp_get_sidebars_widgets(true, true, 'logostrip', true);
$logoWidget = $widgets['logostrip'];
$langs = count(pll_languages_list());
$currentLang = get_option('WPLANG');
for ($i=0; $i < $langs; $i++) {
if ( $logoWidget[$i] ) {
$logoId = $logoWidget[$i];
$i = $langs;
}
}
$title = get_field('header', 'widget_' . $logoId);
$title = preg_replace(array('/[/', '/]/'), array('<', '>'), $title);
$logos = get_field('client_logos', 'widget_' . $logoId);
$maxItems = 6;
?>
Hope this work you.
Instead of pll_current_language(); please use get_option('WPLANG') to get the current language. Please copy and paste the code
<?php
if ( is_active_sidebar('logostrip') ) {
$widgets = wp_get_sidebars_widgets(true, true, 'logostrip', true);
$logoWidget = $widgets['logostrip'];
$langs = count(pll_languages_list());
$currentLang = get_option('WPLANG');
for ($i=0; $i < $langs; $i++) {
if ( $logoWidget[$i] ) {
$logoId = $logoWidget[$i];
$i = $langs;
}
}
$title = get_field('header', 'widget_' . $logoId);
$title = preg_replace(array('/[/', '/]/'), array('<', '>'), $title);
$logos = get_field('client_logos', 'widget_' . $logoId);
$maxItems = 6;
?>
Hope this work you.
answered Nov 21 '18 at 9:55
TristupTristup
2,7891721
2,7891721
Still not using$currentLang
for anything.
– Stender
Nov 21 '18 at 9:56
I have seen that, not getting data is one of the reason to not use. So I explained where the code has been changed. Hope he can undertsand it, otherwise I will explain it to him.
– Tristup
Nov 21 '18 at 10:00
@Stender What would you suggest using then?
– noah f
Nov 21 '18 at 10:00
@noahf, he is actually saying the the variable $currentLang has not been used on your code, so how it can be seen that the language is not fethced. Better you can print it once to check whether the actual langugae is showing or not
– Tristup
Nov 21 '18 at 10:02
1
@Tristup is right - What i am saying is, that you need to implement$currentLang
in your conditions for finding the correct logo. right now, you are just checking, if the first language you hit, exists in your$logoWidget
and then exit your loop - which is where your mistake is.
– Stender
Nov 21 '18 at 10:08
|
show 3 more comments
Still not using$currentLang
for anything.
– Stender
Nov 21 '18 at 9:56
I have seen that, not getting data is one of the reason to not use. So I explained where the code has been changed. Hope he can undertsand it, otherwise I will explain it to him.
– Tristup
Nov 21 '18 at 10:00
@Stender What would you suggest using then?
– noah f
Nov 21 '18 at 10:00
@noahf, he is actually saying the the variable $currentLang has not been used on your code, so how it can be seen that the language is not fethced. Better you can print it once to check whether the actual langugae is showing or not
– Tristup
Nov 21 '18 at 10:02
1
@Tristup is right - What i am saying is, that you need to implement$currentLang
in your conditions for finding the correct logo. right now, you are just checking, if the first language you hit, exists in your$logoWidget
and then exit your loop - which is where your mistake is.
– Stender
Nov 21 '18 at 10:08
Still not using
$currentLang
for anything.– Stender
Nov 21 '18 at 9:56
Still not using
$currentLang
for anything.– Stender
Nov 21 '18 at 9:56
I have seen that, not getting data is one of the reason to not use. So I explained where the code has been changed. Hope he can undertsand it, otherwise I will explain it to him.
– Tristup
Nov 21 '18 at 10:00
I have seen that, not getting data is one of the reason to not use. So I explained where the code has been changed. Hope he can undertsand it, otherwise I will explain it to him.
– Tristup
Nov 21 '18 at 10:00
@Stender What would you suggest using then?
– noah f
Nov 21 '18 at 10:00
@Stender What would you suggest using then?
– noah f
Nov 21 '18 at 10:00
@noahf, he is actually saying the the variable $currentLang has not been used on your code, so how it can be seen that the language is not fethced. Better you can print it once to check whether the actual langugae is showing or not
– Tristup
Nov 21 '18 at 10:02
@noahf, he is actually saying the the variable $currentLang has not been used on your code, so how it can be seen that the language is not fethced. Better you can print it once to check whether the actual langugae is showing or not
– Tristup
Nov 21 '18 at 10:02
1
1
@Tristup is right - What i am saying is, that you need to implement
$currentLang
in your conditions for finding the correct logo. right now, you are just checking, if the first language you hit, exists in your $logoWidget
and then exit your loop - which is where your mistake is.– Stender
Nov 21 '18 at 10:08
@Tristup is right - What i am saying is, that you need to implement
$currentLang
in your conditions for finding the correct logo. right now, you are just checking, if the first language you hit, exists in your $logoWidget
and then exit your loop - which is where your mistake is.– Stender
Nov 21 '18 at 10:08
|
show 3 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53409285%2fcan-not-get-the-current-language-to-appear-in-the-widget%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Where are you using the
$currentLang
variable?– EM-Creations
Nov 21 '18 at 9:51
1
seems like you are not checking if
$currentLang
matches anything.– Stender
Nov 21 '18 at 9:52
also -
$i = $langs;
makes sure, that the first time you hit your forloop, you update the$i
so that you won't hit it again - making sure that you only get the first instance in the loop - that shit needs be go son!– Stender
Nov 21 '18 at 9:54
or should only happen, if you have found the correct logo, using
$currentLang
– Stender
Nov 21 '18 at 9:55
1
Did you try to print_r() the first four variables? That could be helpful
– Lis
Nov 21 '18 at 9:57