php - order results by category, wordpress -
i have category page called 'features' fine, posts in features category belong genre of film, , it's want order posts on actual features category template.
eg
features cat template brings in features posts.
then want display in alpha order whatever genre belongs to
features action post post post comedy post post sci-fi post post
etc.
this have @ moment ( cat numbers relate 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 list posts (group them) genre ? when use title here guess it's using posts title.
playing around if stick in post loop
foreach((get_the_category()) $childcat) { if (cat_is_ancestor_of(4, $childcat)) { echo $childcat->cat_name; } }
this returns actual genre cat each post while in loop, i'm not sure how stick can state ordering of posts groups of genre, hoping in query_posts?
any in right direction appreciated.
i consider first doing query sub categories, , loop through sub categories querying posts each. so:
$categories = get_categories( array ( 'child_of' => 10, 'orderby' => 'name' ) ); foreach( $categories $category ){ // query_posts category $category->term_id // display posts category }
does work wanting do?
Comments
Post a Comment