Custom Post Type = 'projects' with a Hierarchical Taxonomy = 'projects_category'
projects - big-corporates -- company one ---- first project 1 ---- second project 1 ---- third project 1 -- company two ---- first project 2 ---- second project 2 -- company three ---- first project 3 ---- second project 3 ---- third project 3 - small-businesses -- company four ---- first project 4 ---- etc... -- company five -- company six
Below I get a list of all projects listed in 'projects_category' under 'big-corporates' whereas I want to limit the list to just one project from each subcategory of 'big-corporates'.
<?php
global $post;
$args = array( 'post_type' => 'projects', 'projects_category' => 'big-corporates' );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<li><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php #the_title(); ?><?php $terms = get_the_term_list( $post->ID, 'projects_category' ); $terms = strip_tags( $terms ); echo $terms; ?></a></li>
<?php endforeach; ?>
I am trying to achieve a list like this:
company one (links to first project 1) company two (links to first project 2) company three (links to first project 3)
How can I do that?