Skip to content

Instantly share code, notes, and snippets.

@Pushplaybang
Created October 11, 2013 11:00
Show Gist options
  • Select an option

  • Save Pushplaybang/6932956 to your computer and use it in GitHub Desktop.

Select an option

Save Pushplaybang/6932956 to your computer and use it in GitHub Desktop.
<?php $custom_terms = get_terms('mytaxonomyname');
foreach($custom_terms as $custom_term) {
wp_reset_query();
$args = array('post_type' => 'myposttypename',
'mytaxonomyname' => 'taxonomyitem', // might be unneccessary - test this
'tax_query' => array(
array(
'taxonomy' => 'mytaxonomyname',
'field' => 'slug',
'terms' => $custom_term->slug,
'operator' => 'AND',
),
),
);
$loop = new WP_Query($args);
if($loop->have_posts()) {
echo '<h2>'.$custom_term->name.'</h2>';
echo '<dl class="vertical tabs">';
while($loop->have_posts()) : $loop->the_post();
echo '<dd><a href="'.get_permalink().'" title="' . get_the_title() .'">'.get_the_title().'</a></dd>';
endwhile;
echo '</dl>';
}
} ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment