I’m not sure why this isn’t working. I want to exclude categories 406, 982, and 1319 and their children from the list. I don’t see any other arguments on wp codex. Does ‘exclude’ automatically exclude children? Is there another way to do this?
**Edit: I can’t even limit the results to 10.
<?php
$args = array(
'exclude' => '406,982,1319',
'#' => '10'
);
$sidebar_artists = get_categories($args);
echo "<ul>";
foreach ($sidebar_artists as $sidebar_artist) {
echo '<li class="cat-item">' . $sidebar_artist->category_nicename . '</li>';
}
echo "</ul>";
?>
Set parent to 0:
https://codex.wordpress.org/Function_Reference/get_categories
it looks like it should be working but did you try any alternative ? like
is_category
inif/else
? or try exclusion by categoryslug
instead of IDs for sake of debugging….WP Codex Reference for is_category