global $post; $terms = get_terms( 'your-tax' ); foreach( $terms as $term ) { wp_reset_query(); $args = array( 'post_type' => 'your-child-post-type', 'tax_query' => array( array( 'taxonomy' => 'your-tax', 'field' => 'slug', 'terms' => $term->slug, ), ), //get the Custom Field where Types stores the Parent ID 'meta_key' => '_wpcf_belongs_{parent-post-slug}_id', 'meta_value' => $post->ID, ); // if the term has associated posts, show the term and its posts $query = new WP_Query( $args ); if( $query->have_posts() ) { echo '<h3>' . $term->name . '</h3>'; echo '<ul>'; while( $query->have_posts() ) : $query->the_post(); echo '<li>' . get_the_title() . '</li>'; endwhile; echo '</ul>'; } }
Types stores the Parent Post ID in a field called _wpcf_belongs_{parent-slug}_id.
So if you are in one single post (Parent Post) you could query your Child Post type and return only Posts where the _wpcf_belongs_{parent-slug}_id is equal to the current viewed Post (parent) ID.