Social Graphs API: WordPress Plugin: Blogroll Links

If you already know what the Social Graph API and XFN are, you can skip the background information and go directly to the Blogroll Links plugin for WordPress that is designed to work with these.

Update: 2010-Feb-20: Version 2 of the Blogroll Links plugin for WordPress uses the Shortcode API and so introduces a new code-tag format. The new plugin still supports the old (now deprecated) code-tag format for backwards compatibility. See below for examples.

Social Graph API

Google recently announced the Social Graph API.1 From Google’s Code site:

With so many websites to join, users must decide where to invest significant time in adding their same connections over and over. For developers, this means it is difficult to build successful web applications that hinge upon a critical mass of users for content and interaction. With the Social Graph API, developers can now utilize public connections their users have already created in other web services. It makes information about public connections between people easily available and useful.

We (Google) currently index the public Web for XHTML Friends Network (XFN), Friend of a Friend (FOAF) markup and other publicly declared connections. By supporting open Web standards for describing connections between people, web sites can add to the social infrastructure of the web.

The Google Code site also has a video introduction to the open social graph:

YouTube Preview Image

The Google Code site has some interesting example applications. To see the power of the open social graph, follow these links:

All I did was enter my home page into these applications and got the results linked to above.

XHTML Friends Network, a component of open social networks

XFN (XHTML Friends Network) is a simple way to represent human relationships using hyperlinks. In recent years, blogs and blogrolls have become the fastest growing area of the Web. XFN enables web authors to indicate their relationship(s) to the people in their blogrolls simply by adding a ‘rel‘ attribute to their <a href> tags, e.g.:

<a href="" rel="friend met">Home Page: Rajiv Pant</a>

The above link means that the page at belongs to a friend of the person who who owns the page this link is placed on. The met tag specifies that the two friends have met in real life. The link above would not be placed on a page owned by Rajiv Pant. It would be placed by a friend on their page, for example, on

Here is another example:

<a href="" rel="me">Photo Albums: Rajiv Pant</a>

This link states that the page at the URL belongs to the same person who owns the page this link is placed on. For example, the above link would be placed on telling the Web that the URLs and to the same person.

To find out how to write and use XFN, or to write a program to generate or spider it, visit the XFN Web site.

Blogroll Links Plugin for WordPress

For people who maintain their Web site or blog using the WordPress blog content management system, I created an open source plugin called blogroll-links that uses WordPress’ built-in Blogroll feature2 and presents links to friends’ home pages and own pages on social networking sites using XFN in the links.

Features of this plugin

  • It can show the links by category in blog posts and WordPress Pages.
  • It uses WordPress’ standard built-in Blogroll links database. There is no hassle of another list of links to maintain.
  • It can be used to show only the links assigned to a particular category, by stating the category slug as defined in that category’s setting in WordPress.
  • It honors the Show/Hidden setting as defined for each link in WordPress.
  • It displays the link in the same window or new window, as specified for each link in WordPress.

See this plugin in action

    • The two lists, first one of links to my own pages on various social networking sites and the second one of links to some of my friends’ pages are generated by this plugin. Yes, those social networks’ logo pictures are also taken by the plugin from the WordPress standard Blogroll links. Code:
    • <h3>My Pages on Social Networking Sites</h3>
      [blogroll-links categoryslug="rajiv-web" sortby="link_name" sortorder="desc"]
      <h3>Web Sites of Some People I Know</h3>
      [blogroll-links categoryslug="people" sortby="link_name" sortorder="desc"]
    • This list of charitable organizations with brief descriptions is generated by the plugin. Code:
    • [blogroll-links categoryslug="charity"]
    • This list of search engines is maintained as Blogroll links in WordPress. Code:
    • [blogroll-links categoryslug="search-engines"]
    • The featured links shown under the “What’s featured here?” section shows the links I’ve categorized as featured in WordPress’ Blogroll links. Code:
    • <a title="featured" name="featured"></a>
      <h2>What's featured here?</h2>
      [blogroll-links categoryslug="featured" sortby="link_name" sortorder="desc"]

Download & install plugin

  1. WikiPedia article explaining what an API, or application programming interface is. []
  2. It does not make you maintain yet another list of links []

35 thoughts on “Social Graphs API: WordPress Plugin: Blogroll Links”

  1. The plug-in sounds great! Any idea when it might be available for download? I tried the WordPress Plugins Directory but could not find it yet.

    -John @

  2. Helllo, Rajiv.

    Thanks for this plugin. I’d been looking for one that would do exactly this.

    I am not a programmer, so some things get by me, and I wonder if you’d expand your plugin’s documentation. For example, when I see:

    sort-by=”link_name” sort-order=”desc”

    in your examples, I wonder what other value(s) would sort-by accept, and how do I reverse the sort-order (ascending)?

    Again, thanks for the plugin.

  3. A couple of questions!

    1) Is there an option to have a link category open by default? If so, what is it?

    2) Is it possible to update the plugin so as the user can define how the link is displayed? As an example, rather than have the description alongside the link, have it appear on the next line. Or another example remove the list item style and substitute a heading style.

    I am quite surprised with the limited number of blogroll plugins and how some plugins over complicate the process.

    Your plugin is very functional with very little effort required to get it setup and working.


    1. How did you fiddle with yours. I too love the plugin but really would enjoy a way to change the display styling. Maybe a way to toggle ul and li formatting on or off within a plugin option screen would be overkill but any sort of flexibility would be a plus.

  4. Hi, I really like your plugin.

    I would like to know if there is a way to limit the number of link display on a page and automaticaly generate a page #2, 3, 4, 5… for the extra links.

    I have a categorie with more than 300 links and I would like to display them on multiples pages…

    ps. sorry about my english, I'm french…

    Thanks for this cool plugins!


  5. hi rajiv! does the plugin accept sort-by then sort-by? ie, sort by name and then description? if so, what would the code be? thanks!

    1. Hi Ami, It does not have a feature to sort that way yet, but it would not be difficult to add that feature. I’ll add that to the list. Thank you for using this plugin.

  6. Not enough documentation on the blogroll links. Can someone post a text file of parameters and other basic configuration information?

  7. I just upgraded this plug-in to its most recent version.

    It works fine, but when I tried to use the new code instead of the deprecated one, my links doesn't show up.

    I'm not sure why since I am not a programmer, but it's good that the old code still works, at least! Yay for backward compatibility.

    Other than that, thanks so much for making this plug-in. It does exactly what I want.

  8. I installed the plugin today 11 June 2010 but when I go to default settings they are blank. Obviously, I don't know what I'm doing. I'm not new to WP and installing plugins and adjusting settings, but this one has me stumped. I wanted to put my blogroll on a Page for my blog, but I don't know what I'm suppose to do for sure. Do I paste in the code: blogroll-links categoryslug="blogroll" (brackets omitted on purpose) into the HTML section tab? Please help me use the wonderful plugin. Thank you very much.

    1. I was having the same problem, so I went to look at the code in blogroll-links.php, and found out why it was loading so slowly.

      Here is the "Sample SQL Query" that is shown as a comment in the code:

      Sample SQL Query:
      SELECT *
      FROM wp_links, wp_term_relationships
      WHERE link_id = object_id
      AND link_visible = 'Y'
      AND term_taxonomy_id = (
      SELECT wp_term_taxonomy.term_taxonomy_id
      FROM wp_term_taxonomy
      WHERE term_id = (SELECT DISTINCT term_id
      FROM wp_terms, wp_term_relationships
      WHERE slug = 'charity'
      AND taxonomy = 'link_category'))
      ORDER BY link_name

      The fourth line from the bottom – "FROM wp_terms, wp_term_relationships" – is causing the problem. The two tables are not joined in the WHERE clause below that, and there is no reason for wp_term_relationships to be there at all – having it there just causes full table scans to take place that aren't necessary.

      Of course, this is just the comment part of the code, so it's the actual PHP code below this that needs to be modified. I edited this line…

      "FROM " . $table_prefix . "terms, " . $table_prefix . "term_relationships " .

      …and changed it to this…

      "FROM " . $table_prefix . "terms " .

      …and now my Links page – – opens in a split second.

      Luckily, I'm familiar with SQL and PHP, so I was able to find & fix this. Most users of the plug-in probably aren't, though, so hopefully an update will be released, as it's a very simple fix.

  9. Hello Rajiv

    I have been trying to find a plugin for WP that would allow me to display the links in my blogroll onto my pages. I found two that seem to work, yours and one called Link Library. Link Library is complicated and does not format the information well.

    Your plugin is much simpler and the output format is much cleaner. I do have one request if you can direct me on how to implement this, your plugin would be perfect.

    The website being built in WP is informational in nature. I have several dozen pages that I have set up to display only the links to providers on each specific page. When I set up the link, I don't use the description section, but rather the notes in the Advanced section of the add new links admin page. I want to display that notes information with the link. How would I do that?

    You can contact me at [email protected]


  10. Anyone discovered some variable list or something for this plug? I've tried using both sortorder="random" and sortorder="rand" in the shortcode, but neither work.

    Also, no matter what I put into the text fields in the settings, when I save, they're blank again. I'm running WP 3.0 in multisite mode.

  11. I have a problem – the "sortorder" parameter doesn't work. I need to sort links by ID (it's ok) – descending. But [… sortorder="desc"] does nothing… :-/ Pls help. (WP version 3.0.3)

  12. Excellent information. I have pointed my readers to it in my article about the Blogroll and Links.
    Thank you for your help.

    Andy Moore

Leave a Reply