Custom display of Links

Gain total control over the way your theme displays your links / bookmarks / blogroll.

I didn’t like the way my links came out with wplistbookmarks or any other built-in function, so I needed a way to have total control about the way my WordPress bookmarks were displayed. In this example I wanted a table with the Bookmark-image in the left column and title and description in the right column.

This should probably go into a separate page template but should basically work anywhere in your theme.

Code Snippet:

//get links from database (works outside of loop)
$links = $wpdb->get_results("SELECT * FROM $wpdb->links ORDER BY link_name ASC");

  //start the table
  echo "<table border='0' class='linktable'>";
    //start going through all the links and get the required values for each link
    foreach ($links as $link) {

      //write a table row for each link with the link image in the left cell and name and description in right cell
      echo "<tr><td><a href='$linkurl' target='_blank'><img src='$linkimage' alt='$linkurl' border='0' class='linkimg'></a></td>";
      echo "<td valign='top' class='link-desc'><h5>$linkname</h5>";
      echo "<div class='link-description'>$linkdesc </div></td></tr>";
//finish going through all the links
echo "</table>";
//close the table

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!