Guest User

Untitled

a guest
Jun 18th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. <?php
  2.  
  3. hierarchical_category_tree( 0 ); // the function call; 0 for all categories; or cat ID
  4.  
  5. function hierarchical_category_tree( $cat ) {
  6. // wpse-41548 // alchymyth // a hierarchical list of all categories //
  7.  
  8. $next = get_categories('hide_empty=false&orderby=name&order=ASC&parent=' . $cat);
  9.  
  10. if( $next ) :
  11. foreach( $next as $cat ) :
  12. echo '<ul><li><strong>' . $cat->name . '</strong>';
  13. echo ' / <a href="' . get_category_link( $cat->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $cat->name ) . '" ' . '>View ( '. $cat->count . ' posts )</a> ';
  14. 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>';
  15. hierarchical_category_tree( $cat->term_id );
  16. endforeach;
  17. endif;
  18.  
  19. echo '</li></ul>'; echo "\n";
  20. }
  21. ?>
Add Comment
Please, Sign In to add comment