Ask your WordPress questions! Pay money and get answers fast! (more info)

custom sidebar in homepage and translated homepage WordPress

  • SOLVED

I have
1) home page
2) translated homepage with WPML

And (custom sidebar plugin)
1) custom sidebar (2 text fields) for homepage
2) custom sidebar (2 text fields) for translated homepage

I inserted the following widget logic (plugin widget logic)


is_page('home')
in the homepage customized widget (in both the 2 text fields)

is_page('hometranslated')
in the translated homepage customized widget (in both the 2 text fields)

Objective:
home -> custom sidebar
home translated -> custom sidebar translated

But it does not work.

The result is:
home -> custom sidebar
home translated -> custom sidebar (the same as above and not the translated sidebar)

The displayed widget is always one, the "front-page" sidebar location.
No way to insert the custom sidebar in a "translated front page"

What could be done?

Answers (2)

2015-02-01

Romel Apuya answers:

use

use the constant
ICL_LANGUAGE_CODE
for checking the langauge...

where en = english, fr = french


if(ICL_LANGUAGE_CODE=='en'){

}else{

}

you need to change the

if(ICL_LANGUAGE_CODE=='en') to your base language..

[[LINK href="http://wpml.org/documentation/support/wpml-coding-api/"]]http://wpml.org/documentation/support/wpml-coding-api/[[/LINK]]





Romel Apuya comments:

since you are using widget logic you can use

1. is_page('home') && (ICL_LANGUAGE_CODE=='en')
2. is_page('home') && !(ICL_LANGUAGE_CODE=='en')

just change (ICL_LANGUAGE_CODE=='en') to your base language


noronha comments:

<blockquote>what is hometranslated in is_page('hometranslated')? is it the slug?</blockquote>

Yes.

<blockquote>use the constant
ICL_LANGUAGE_CODE
for checking the langauge...

where en = english, fr = french


if(ICL_LANGUAGE_CODE=='en'){

}else{

}

you need to change the

if(ICL_LANGUAGE_CODE=='en') to your base language..</blockquote>


Where exactly I have to insert the code?


<blockquote>since you are using widget logic you can use

1. is_page('home') && (ICL_LANGUAGE_CODE=='en')
2. is_page('home') && !(ICL_LANGUAGE_CODE=='en')

just change (ICL_LANGUAGE_CODE=='en') to your base language</blockquote>

it does not work... if I insert these logics, the custom sidebar disappear (both, english and translated) and it shows a basic sidebar...


Romel Apuya comments:

use is_home instead

is_home() && (ICL_LANGUAGE_CODE == 'en')
is_home() && !(ICL_LANGUAGE_CODE == 'en')


Romel Apuya comments:

but if is_home() wont work try is_page($pageid) where $pageid is the id of the home page.

$pageid =10;
(ICL_LANGUAGE_CODE == 'en') && is_page($pageid)


i've read that is_home seems nt working its a plugin issue of widget logic.


Romel Apuya comments:

(ICL_LANGUAGE_CODE == 'en') && is_page(10)


noronha comments:

I inserted is_home but the situation does not change.

If i insert is_home in the logic box, the custom box disappear - in its place a basic setting sidebar



noronha comments:

neither pageid...


Romel Apuya comments:

[[LINK href="https://khromov.wordpress.com/2012/07/17/common-uses-for-widget-logic/"]]https://khromov.wordpress.com/2012/07/17/common-uses-for-widget-logic/[[/LINK]]


Romel Apuya comments:

perhaps you can try is_front_page();

is_front_page() && (ICL_LANGUAGE_CODE == 'en')
is_front_page() && !(ICL_LANGUAGE_CODE == 'en')


Romel Apuya comments:

is_page(array(10)) && (ICL_LANGUAGE_CODE == 'en')
is_page(array(10)) && !(ICL_LANGUAGE_CODE == 'en')

replace 10 with the id of the home


noronha comments:

Unfortunately it does not work any parameter.
Maybe, for unknown reasons, widget logic does not work properly.

Is there a code I can insert not via widget logic?


<blockquote>
check the option 'wp_reset_query' in widget logic settings... and try is_page('hometranslated') again...
</blockquote>

I don't understand... You mean in widget_logic.php file?


noronha comments:

I inserted flag

Use 'wp_reset_query' fix

in the settings with default option,

but the problem remains.


Romel Apuya comments:

now we need to isolate.. just use on the first widget

ICL_LANGUAGE_CODE == 'en'

and

!(ICL_LANGUAGE_CODE == 'en')

on second widget

2015-02-01

Reigel Gallarde answers:

what is hometranslated in is_page('hometranslated')? is it the slug?


Reigel Gallarde comments:

check the option 'wp_reset_query' in widget logic settings... and try is_page('hometranslated') again...