<?php
$args = array(
\'type\' => \'itineraries\',
\'child_of\' => 0,
\'parent\' => \'\',
\'orderby\' => \'name\',
\'order\' => \'ASC\',
\'hide_empty\' => 1,
\'hierarchical\' => 1,
\'exclude\' => \'\',
\'include\' => \'\',
\'number\' => \'\',
\'taxonomy\' => \'travel_locations\',
\'pad_counts\' => false );
$categories = get_categories($args);
$attachments = get_children( $args );
foreach ($categories as $category):
// set up a new query for each category, pulling in related posts.
$services = new WP_Query(
array(
\'post_type\' => \'itineraries\',
\'showposts\' => -1,
\'tax_query\' => array(
array(
\'taxonomy\' => \'travel_locations\',
\'terms\' => array( $category->slug ),
\'field\' => \'slug\'
)
)
)
);
?>
<h3><?php echo $category->name; ?></h3>
<ul>
<?php while ($services->have_posts()) : $services->the_post(); ?>
<li><?php the_title(); ?></li>
<?php endwhile; ?>
</ul>
<?php
// Reset things, for good measure
$services = null;
wp_reset_postdata();
// end the loop
endforeach;
?>