title: Get only parent categories wordpress
body: <p>i'm trying to create a category list, but i only want to list the parent categories and not the child categories. How can i do this? so far i've created a list, which list all parent and child categories.</p>
  
  <pre><code>function categoryList() {
  
  
    $args = array(
    'orderby' =&gt; 'name',
    'order' =&gt; 'ASC'
    );
  $categories = get_categories($args);
  
    $output .= '&lt;ul class="category-list"&gt;';
    foreach($categories as $category) { 
            if ($category){
            $output .= '&lt;li&gt;&lt;a href="' . get_category_link( $category-&gt;term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category-&gt;name ) . '" ' . '&gt;' . $category-&gt;name.'&lt;/a&gt;';
            }
    } 
  
    $output .= '&lt;/li&gt;';
    $output .= '&lt;/ul&gt;';
  
    return $output;
  
  }
  </code></pre>