Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. $terms = get_terms('resource_category'); // Taxonomy name
  5. echo '<ul>';
  6. foreach($terms as $term) {
  7. $posts = get_posts(
  8. array(
  9. 'post_type' => 'Resources', // Post type
  10. 'tax_query' => array(
  11. array(
  12. 'taxonomy' => 'resource_category', // Taxonomy name
  13. 'field' => 'slug',
  14. 'terms' => $term->slug
  15. )
  16. ),
  17. 'posts_per_page' => -1
  18. )
  19. );
  20. echo '<li>' . $term->name;
  21. echo '<ul>';
  22. foreach($posts as $post) {
  23. echo '<li><a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a></li>';
  24. }
  25. echo '</ul></li>';
  26. }
  27. echo '</ul>';
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement