Below is a list of scripts that contains a list of categories on the site (excluding those listed in the "without heading" section).
If possible, I would like to change it so that it only displays top-level categories (without child categories) ...
I thought the argument "depth" = 1 would do the trick, but not like that. It lists ALL categories. When I remove the “hierarchical” argumentation, it excludes the child categories, but then also includes the “uncategorized” category, which I explicitly exclude with the exclude_tree = 1 argument.
Into the abyss. Check WordPress 3.0.1.
$cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h);
$cat_args['title_li'] = '';
$cat_args['exclude_tree'] = 1;
$cat_args['depth'] = 1;
wp_list_categories(apply_filters('widget_categories_args', $cat_args));
source
share