it's my first post here on stackoverflow after finding help for tons of questions- Thank you so far.
I'm building a wordpresstheme within Wordpress 3.0.4.
Theres's a navigation: Home | comedy | scifi | action | arthouse
I have set up some custom post types like "reviews".
Taxonomy = films
slugs = comedy, scifi, action, arthouse
I also added the possibility to acitivate a custom field "feature" inside every post.
On the front end startpage all posts from custom post type "reviews" are shown.
Now theres a button "featured" - when see visitor clicks that button, only posts with customfield "featured" shall be shown.
The content should be loaded with AJAX.
I know how to load stuff with AJAX from another page inside wordpress.
E.g.: I'm using:
<script type="text/javascript">
$(document).ready(function(){
$.ajaxSetup({cache:false});
$("#featured a").click(function(){
var post_id = $(this).attr("rel")
$(".wrapper").html("loading...");
$(".wrapper").load(jQuery(this).attr("href") + " .wrapper")
return false;
});
});
</script>
so when someone click the button "featured" ajax loads a .wrapper part from another page:
<?php
query_posts( array(
'post_type' => 'reviews',
'taxonomy' => 'films',
'meta_key' => 'featured',
'meta_value' => 'yes',
'posts_per_page' => 10
));
?>
so the query is kind of "fake filtered". But that only works for one slug/category e.g. "arthouse" not dynamically.
When the visitor goes to a specific page e.g. "arthouse" - only posts of custom post type films are shown with slug "arthouse".
Using this query:
<?php query_posts('films=arthouse'); ?>
Now the question: How can I get wordpress to understand, that "onclick" the featured button only the posts with "featured" = "yes" are shown inside the slug "arthouse"?
Is there some js filter I could use? GET handler? Or what would be the right way?
I really appreciate some help!
thank you!
ad
But how can I make something happen with just a click?
Is there a way to let jquery handle a php query?
I know how to query posts with more than one taxonomy like in this post here: https://wordpress.stackexchange.com/questions/7107/how-to-filter-custom-posts-by-tags-and-custom-fields
but how can I do it with ajax - without a pagereload? Like this somehow:
http://www.wpthemetoolset.com/filterable/#all
thank you very much!!!
AD