Display Total Number of Blogroll Bookmarks

Posted on: November 4, 2010 by Jeff Starr

Quick WordPress tip for you today! A reader recently asked about displaying the total number of blogroll bookmarks on their site. This sounds simple enough but not everyone meddles with code these days, so here is a nice PHP snippet that will do the job:

<?php $numlinks = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links WHERE link_visible = 'Y'");
if (0 < $numlinks) $numlinks = number_format($numlinks); ?>

Place that in your theme file and then customize the output by placing <?php echo $numlinks; ?> wherever you would like to display the results.

A perfect example of this code in use can be seen at this random bookmark site.

Thumb for Display Total Number of Blogroll Bookmarks

Let's talk it out, folks.

  1. have a excellent site. I read all your post and 45 pages . thank you

    #1
  2. Julian said on November 17, 2010:

    why don’t you use

    $wpdb->get_var("SELECT * FROM $wpdb->links WHERE link_visible = 'Y'");

    #2

Comments are closed. If you have something really important to add, contact us. Thank you!