Check if bookmarks exist on your blog

The problem

Wished you could check if any bookmarks exist on your blog?

The solution

Here’s how. Five lines of PHP Code:

$bm = get_bookmarks(array());
$bm_count = count($bm);
if($bm_count > 0) {
  wp_list_bookmarks('title_li=');
}

What does it do?

We use the function get_bookmarks() to count the number of bookmarks. If it returns 0, there are no bookmarks. Pretty easy, huh?

Requirements

  • WordPress 2.1 and above

Tags: ,

Leave a comment