I'm trying to hide the empty categories (with no posts associated) from a list in an archive page.
I'm using hide_empty
as suggested on Wordpress codex but it's not working, the code outputs all categories:
<ul class="filter-menu">
<?php $cat = get_query_var('cat');
foreach(get_categories('parent=0&hide_empty=1') as $category) {
echo '<li><a href="#" data-filter=".'. $category->slug.'" >' . $category->name.'</a></li>';
}
?>
</ul>
Any idea what I'm doing wrong or how could I modify the code to make it work?
0
for those in question.