Wordpress current category's sub-categories list

categories, php, wordpress

Solution

Replace $args with:

$current_cat = get_queried_object();

$args = array( 'child_of' => $current_cat->term_id, );

Problem

How i can list current category's subcategories list. i'll try get_categories code but i can't. like that ; ``` $args = array('child_of' => term_id ); $categories = get_categories( $args ); foreach($categories as $category) { echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> '; echo '<p> Description:'. $category->description . '</p>'; echo '<p> Post Count: '. $category->count . '</p>'; ```

Original source