codebloo

Wordpress - parent child post loop

Feb 8th, 2017
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. <?php
  2. foreach( get_terms( 'types', array( 'hide_empty' => false, 'parent' => 0 ) ) as $parent_term ) {
  3. // display top level term names + display
  4. echo '<div class="archive_box"><header><h3>'. $parent_term->name . '</h3></header>';
  5.  
  6. foreach( get_terms( 'types', array( 'hide_empty' => true, 'parent' => $parent_term->term_id ) ) as $child_term ) {
  7. // display name of all Children of the parent term
  8. echo '<div class="tax_section"><h3 class="tax_name">'. $child_term->name . '</h3>';
  9. echo '<ul class="archive_content">';
  10.  
  11. //Loop goes here!
  12. // WP_Query custom post type "archives", display 3 latest posts from the current CHILD term
  13.  
  14. echo '<li><a href="permalinkhere">POSTNAMEHERE <i class="fa fa-arrow-circle-o-right" aria-hidden="true"></i></a></li>';
  15.  
  16. //end loop
  17. echo'</ul><a href="'. $child_term->slug .'" class="button">More '. $child_term->name .'</a></div>';
  18. }
  19. //end archivebox
  20. echo '</div>';
  21. } ?>
Advertisement
Add Comment
Please, Sign In to add comment