Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 4 replies, has 3 voices.

Last updated by johan 9 years ago.

Assigned support staff: Harshad.

Author Posts
December 17, 2012 at 1:59 am #91050


Hi Guys,

I think I may have found a slight bug with WP 3.5 and the get_ls_languages function of the main SitePress class, and I just wanted to let you guys know about it.

I have a plugin where I register different sets of options based on the WPML languages the user has setup, and so I have a function that is hooked to admin_init where I call icl_get_languages.

function my_options(){
	$langs = icl_get_languages();
	// do stuff with $langs...
add_action( 'admin_init', 'my_options' );

Since upgrading to WP 3.5, any page in the admin panel that has a query of posts is now broken. For example, when I go to the "Posts" admin panel, it tells me there are no posts on my site (see attached screenshot).

So, I had a look at the get_ls_languages of the SitePress class, and it appears to be some kind of issue with how the query is being reset after determining the languages. I was able to fix the issue from my plugin by calling wp_reset_query after retrieving the languages:

function my_options(){
	$langs = icl_get_languages();
	// do stuff with $langs...
add_action( 'admin_init', 'my_options' );
Screen Shot 2012-12-16 at 4.52.11 PM.png
December 17, 2012 at 7:06 am #91066


Dear Jason,

Thanks for sharing this information, I will pass this information to our development team and check it gets fixed.

December 21, 2012 at 10:50 pm #92745


So after the upgrade to v2.6.3, it appears the icl_get_languages function no longer works within the admin panel at all. It simply returns a blank array no matter where it's hooked in.

This is how I'm able to retrieve the languages in v2.6.3, but I'm not sure if making icl_get_languages not work was WPML's intention.

function example(){
	global $sitepress;
	$langs = $sitepress->get_active_languages();
add_action( 'admin_init', 'example' );
December 22, 2012 at 9:22 am #92780


We have updated the get_ls_languages function of the main SitePress class.

December 27, 2012 at 10:19 pm #93326



Is the new behaviour of icl_get_languages (not returning languages inside admin panel) intended or is it a bug?

If intended: Is JasonB1's method the recommended way to retrieve languages?

Need to know, one of my plugins uses icl_get_languages and will stop working if I upgrade!

best regards Johan Linderoth

The topic ‘[Closed] Calling icl_get_languages with WP 3.5 and resetting query’ is closed to new replies.