I have a set of schools in a custom post type with locations ordered as follows:
London
- 1 Oxford Road
- 2 Cambridge Road
Paris
- 1 Napoleon Road
- 2 Tower Road
How do I change the following so that the location parent is outputted instead of the location child:
// begin loop
$args = array('post_type' => 'school');
query_posts($args); if ( have_posts() ) : while ( have_posts() ) : the_post();
// variable for location
$location = get_the_term_list( $post->ID, 'location', '', ', ', '' );
// output
echo get_the_title() . ' - ' . $location;
// end loop
endwhile; endif;
Thank you.