age*_*nel 4 php wordpress categories
我如何列出当前类别的子类别列表。
我将尝试get_categories代码,但不能。
像那样 ;
$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>';
Run Code Online (Sandbox Code Playgroud)
将$ args替换为:
$current_cat = get_queried_object();
$args = array( 'child_of' => $current_cat->term_id, );
Run Code Online (Sandbox Code Playgroud)