I've got a js file like this:
var category = [];
var genre = [];
var type = [];
var mainContent = jQuery('#content');
var siteURL ="http://" + top.location.host.toString();
var URL = siteURL + "/?category="+ category +"&genre=" + genre +"&type="+ type +" #content";
jQuery('.ajax-cb').each(function() {
jQuery(this).click(function() {
mainContent.load(URL,function(){
mainContent.animate({opacity: '1'});
});
});
});
It does load GET[] parameters to change the loop,
in the theme's function.php I've got:
function pre_selected_results() {
$taxquery = array(
'relation' => 'OR',
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => $_GET['category'],
'operator'=>'IN'
),
array(
'taxonomy' => 'genres',
'field' => 'slug',
'terms' => $_GET['genre'],
'operator'=>'IN'
),
array(
'taxonomy' => 'types',
'field' => 'slug',
'terms' => $_GET['type'],
'operator'=>'IN'
)
);
$stack[] = "dog";
$the_query = new WP_Query($myquery);
while ($the_query->have_posts()) :
//the loop
//I then collect info from the loop displayed
$args = array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'slugs');
$results = wp_get_post_terms(get_the_ID(),'category',$args);
foreach ($results as $result){
array_push($stack, $result);
}
endwhile;
/*And I use wp_localize_script(); to send $stack back to js*/
wp_enqueue_script( 'feedback' );
wp_localize_script( 'feedback', 'jsdata', $stack);
}; //end of pre_selected_results
On my home page I call pre_selected_results(); the loop display fine and refresh,
but $stack only refresh if I edit the URL with GET[] manually in the browser,
otherwise it just return 'dog', anything obvious to you that I'm missing?