Like the blog? Get the book »

Display Total Number of Blogroll Bookmarks

Display Total Number of Blogroll Bookmarks

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. You can add this code anywhere in your theme template (wherever you want to display the total number of Blogroll links).

<?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. Nifty!

3 responses

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

  2. why don’t you use

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

Comments are closed for this post. Contact us with any critical information.
© 2009–2024 Digging Into WordPress Powered by WordPress Monzilla Media shapeSpace