DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

Did you ever want to display how many blogroll links you have in total? If yes, just read this recipe. It’s pretty easy to do using the $wpdb object and some SQL.

Simply paste the following code where you want the count to be displayed:

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

Thanks to Jeff Starr for this tip!


One Comment

  1. Thanks for this. It works perfectly on my blog. I use it to say something like “We currently have X links that we’d like to share with you”. The value of X updates as contributors add or remove blogroll links.

    A nice tip!

Leave a Comment

Your email address will not be published. Required fields are marked *