Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $terms = get_terms('resource_category'); // Taxonomy name
- echo '<ul>';
- foreach($terms as $term) {
- $posts = get_posts(
- array(
- 'post_type' => 'Resources', // Post type
- 'tax_query' => array(
- array(
- 'taxonomy' => 'resource_category', // Taxonomy name
- 'field' => 'slug',
- 'terms' => $term->slug
- )
- ),
- 'posts_per_page' => -1
- )
- );
- echo '<li>' . $term->name;
- echo '<ul>';
- foreach($posts as $post) {
- echo '<li><a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a></li>';
- }
- echo '</ul></li>';
- }
- echo '</ul>';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement