function process_cat_tree($cat) { $args = array('category__in' => array($cat), 'numberposts' => -1, 'orderby' => title, 'order' => ASC); $cat_posts = get_posts($args); if ($cat_posts) { foreach ($cat_posts as $post) { echo '<li>'; echo '<a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a>'; echo '</li>'; } } $next = get_categories('hide_empty=0&parent=' . $cat); if ($next) { foreach ($next as $cat) { echo '<ul><li><strong>' . $cat->name . '</strong></li>'; process_cat_tree($cat->term_id); } } echo '</ul>'; }
function process_cat_tree($cat) { $args = array('category__in' => array($cat), 'numberposts' => -1, 'post_type' => 'downloads-data'); $cat_posts = get_posts($args); if ($cat_posts) { echo '<ul>'; foreach ($cat_posts as $post) { echo '<li><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a></li>'; } echo '</ul>'; } $next = get_categories('hide_empty=0&parent=' . $cat); if ($next) { echo '<ul class="sub_cat_list">'; foreach ($next as $cat) { echo '<li class="sub_cat">' . $cat->name . '</li>'; process_cat_tree($cat->term_id); } echo '</ul>'; } }