Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- hierarchical_category_tree( 0 ); // the function call; 0 for all categories; or cat ID
- function hierarchical_category_tree( $cat ) {
- static $depth=0;
- // wpse-41548 // v1.3 // structured nested list // alchymyth // a hierarchical list of all categories //
- $next = get_categories('hide_empty=0&orderby=name&order=ASC&parent=' . $cat);
- if( $next ) :
- $depth++;
- echo "\n"; for($i=1;$i<$depth;$i++) echo ' '; //for structured html output
- echo '<ul class="depth-'.$depth.'">';
- foreach( $next as $cat ) :
- echo "\n "; for($i=1;$i<$depth;$i++) echo ' '; //for structured html output
- echo '<li><strong>' . $cat->name . '</strong>';
- echo ' / <a href="' . get_category_link( $cat->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $cat->name ) . '" ' . '>View ( '. $cat->count . ' posts )</a> ';
- echo ' / <a href="'. get_admin_url().'edit-tags.php?action=edit&taxonomy=category&tag_ID='.$cat->term_id.'&post_type=post" title="Edit Category">Edit</a>';
- hierarchical_category_tree( $cat->term_id );
- echo '</li>';
- endforeach;
- echo "\n"; for($i=1;$i<$depth;$i++) echo ' '; //for structured html output
- echo '</ul><!--/.depth-'.$depth.'-->';
- $depth--;
- echo "\n "; for($i=1;$i<$depth;$i++) echo ' '; //for structured html output
- endif;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement