I have a news page where posts are dynamically loaded based upon which category in the menu is clicked. This is done through Javascript/AJAX. The site is multi language and I'm using WPML to switch between languages. This works absolutely fine everywhere on the site, but as soon as I try to exclusively echo posts from the other language through AJAX, it doesn't work.
It displays absolutely nothing even if the category ID is correct.
The code I am using in AJAX is as follows;
query_posts( array('posts_per_page' => $posts, 'paged' => 1, 'category__in' => $selectedCategory, 'lang' => $curLang));
Now I've tested if the current language was not being parsed correctly, but even statically putting in 'en' didn't change a thing, it still wouldn't echo the english posts through Ajax. The code however works fine in a regular old PHP file.
The javascript I'm using to fill the variables in to pass to AJAX is as follows:
var load_posts = function(postMax, category){
$.ajax({
type : "POST",
dataType : "html",
url : siteurl + "ajax/?postMax="+postMax+"&numPosts=6&pageNumber="+page+"&category="+category+"currentLang="+curLang,
beforeSend : function(){
},
success : function(data){
if(page <= 6){
content.empty();
content.append(data);
$('.more-link').each(function(){
var tempLink = $(this).attr('href');
$(this).parent().parent().parent().parent().children('a').attr('href', tempLink);
});
loading = false;
if(page === 3){
$('#nieuwsContent').css("padding-top", "10px");
}
page++;
}
},
error : function(jqXHR, textStatus, errorThrown) {
alert(jqXHR + " :: " + textStatus + " :: " + errorThrown);
}
});
};
I'm at a complete loss as to what I should be doing to fix this.