I would like to display one post (oldest, but that's not that important for now) out of each of the custom category except one (called 'home').
So far I got to
1) display each custom taxonomy slug existing except one that I don't need.
2) display all custom posts of a certain taxonomy ('portraits')
How do I do the third and main part of the script - display one post from each of the custom taxonomy?
//get all custom categories (taxonomy)
$terms = get_terms(array('taxonomy' => 'album', 'exclude' => 4));
foreach ($terms as $term){
echo $term->slug;
echo "<br/>";
}
//get all custom post types of custom category "portraits"
//however, need to get one oldest post of each custom category from above
$args = array(
'post_type' => 'simple_image',
'posts_per_page' => '-1',
'order_by' => 'date',
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'album',
'field' => 'slug',
'terms' => 'portraits'
)
)
);
$new_query = new WP_Query ($args);
while ( $new_query->have_posts() ) : $new_query->the_post();
the_post_thumbnail('thumbnail') ;
endwhile;
And why I am doing it - it's a photo gallery theme and I want to display a list of albums with a thumbnail. The thumbnail will come from one of the posts in the album.
[edit] I've seen a script where WP query was put in the foreach loop, that doesn't make much sense to me. Is there something simpler? Isn't there JOIN operation?