Last active
August 29, 2015 14:21
-
-
Save jonkpirateboy/6fdba227e10e7fea39ac to your computer and use it in GitHub Desktop.
Sort by taxonomy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$timestamps = get_terms( 'timestamp', array( | |
'hide_empty' => true, | |
'orderby' => 'name', | |
) ); | |
if ( ! empty( $timestamps ) && ! is_wp_error( $timestamps ) ){ | |
echo '<ul>'; | |
foreach ( $timestamps as $timestamp ) { | |
echo '<li>' . $timestamp->name . '</li>'; | |
$args = array('post_type' => 'event', | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'timestamp', | |
'field' => 'name', | |
'terms' => $timestamp->name, | |
), | |
), | |
); | |
$myposts = get_posts( $args ); | |
foreach ( $myposts as $post ) : setup_postdata( $post ); ?> | |
<li> | |
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> | |
</li> | |
<?php endforeach; | |
wp_reset_postdata(); | |
} | |
echo '</ul>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment