Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. <?php $cat = 'Work';
  2. $catID = get_cat_ID($cat);
  3. $subcats = get_categories('child_of=' . $catID);
  4.     foreach($subcats as $subcat) {
  5.     echo '<h3>';
  6.     echo '<a href="' . get_category_link($subcat->cat_ID) . '">';
  7.     echo '/' . $subcat->cat_name . '';
  8.     echo '</a></h3>';
  9.     echo '<ul>';
  10.     $subcat_posts = get_posts('cat=' . $subcat->cat_ID);
  11.     foreach($subcat_posts as $subcat_post) {
  12.         $postID = $subcat_post->ID;
  13.     echo '<li>';
  14.     echo '<a href="' . get_permalink($postID) . '">';
  15.     echo get_the_title($postID);
  16.     echo '</a></li>';
  17.     }
  18.     echo '</ul>';
  19. } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement