I am working on an advanced search on wordpress based on custom taxonomies. I'm stuck since 48h so I was hoping to have some help or thought...
Step 1 --- in the js file the query strings are created like that:
if (jQuery('#s').val() == ''){
URL = "/?genre=" + genre + '...other Stuff' #content';
}else{
URL = "/?s="+searchQueryString+"&genre=" + genre +'...other stuff' #content';
}
It nicelly load my custom loop in my #content div without changing the browser url or reloading the header, which is pretty good...so far. :-)
Step 2 --- then I wrote 2 functions in my function.php , one to load the loop with the GET[] elements on main page, using new WP_Query
and one that does the same thing for search queries:
add_action('pre_get_posts','SearchFilter');
Which is compiling my GET[] filters with the GET[s] in the content.php, Still all good....
Step 3 --- (problem^^)---
I want to add a css class to desactivate the radio buttons located in my header.php, depending on the results in the loop.
Try-1 I thought I could create a php array to compile the terms found while the loop is happening, and then compare it with my buttons value.like that:
$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);
}
But there is no way to retrieve the data from that array in the header afterwhile, or to create it from the header using things like global $post;
since my url doesn't change.
it just shows the homepage query.
Try-2 I also thought I could encode it to json and then put some action in my js file. but so far it just return json unexpected character, and I got the feeling that even if I crack it, its not going to be the right way since its going to make the js file heavier.
May be I'm just missing something about the Global wp_query and I don't need to charge my script?
Excuse my english and the long question,
thanks a lot in advance if you have an idea,
DACO