Show parent-child relationship for categories in the wordpress admin

EDIT:

On a post page, the categories are already seen in hierarchical manner but with checkboxes. So, I have assumed that you have to show list of all the categories/subcategories somewhere in the admin panel in following format.

  • Category 1
    • Sub-Category 1.1
    • Sub-Category 1.2
  • Category 2

So, presentation is upto you, I have just given logic to pull the necessary data i.e. list of all the categories along with subcategories.

    $arg1 = array(
        'parent'                   => 0,
        'orderby'                  => 'name',
        'hide_empty'               => 0,
        'pad_counts'               => false 
        );

    $categories = get_terms('category', $arg1);  //or use your custom taxonomy name

    if( !empty($categories) && is_array($categories) ){

      echo '<ul>'; 

      foreach($categories as $cat){

        echo '<li>'.$cat->name;

        $arg2 = array(
                        'child_of'                 => $cat->term_id,
                        'orderby'                  => 'name',
                        'hide_empty'               => 0,
                        'pad_counts'               => false 
                    );

        $sub_categories = get_terms('category', $arg2); //or use your custom taxonomy name

        if(!empty($sub_categories) && is_array($sub_categories)){

          echo '<ul>';       

          foreach($sub_categories as $scat){

              echo '<li>'.$scat->name.'</li>';
          }
      echo '</ul>';
      }
      echo '</li>';
      }
    echo '</ul>';
    }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)