I have a category page called ‘features’ this is all fine, but the posts in the features category also belong to a certain genre of film, and it’s this what I want to order the posts by on the actual features category template.
eg
features cat template brings in all features posts.
then what I want to do is display in alpha order by whatever genre it also belongs to
features
action
post
post
post
comedy
post
post
sci-fi
post
post
etc.
this is what I have at the moment ( the cat numbers relate to the genres = action=10 etc)
query_posts('cat=10,11,12,13,14,15,16,17,18&orderby=title&order=DESC' );
while (have_posts()) : the_post();
How can I list all the posts (group them) by genre ? when I use title here i guess it’s using the posts title.
Playing around if I stick this in the post loop
foreach((get_the_category()) as $childcat) {
if (cat_is_ancestor_of(4, $childcat)) {
echo $childcat->cat_name;
}
}
this returns the actual genre cat for each post while in the loop, but I’m not sure how to stick it together so I can state the ordering of the posts by groups of genre, I was hoping I could do this in the query_posts?
Any help in the right direction would be greatly appreciated.
I would consider first doing a query for your sub categories, and then loop through your sub categories querying the posts for each. Like so:
Does that work for what you are wanting to do?