Hiding Empty Link Categories
-
Hi. I tried searching for this answer but I didn’t really find anything.
I’m using the following code from the wiki to display links grouped by category in the sidebar:
<ul>
<?php
$link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
foreach ($link_cats as $link_cat) {
?>
<li id="linkcat-<?php echo $link_cat->cat_id; ?>"><h2><?php echo $link_cat->cat_name; ?></h2>
<ul>
<?php wp_get_links($link_cat->cat_id); ?>
</ul>
</li>
<?php } ?>
</ul>It works well, but I’d like to modify it so that any empty categories (those without any links) are not displayed. I’ve no idea how to do it myself; I’d greatly appreciate any assistance.
Thanks!
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Hiding Empty Link Categories’ is closed to new replies.