Webucator Blog

How to share links among WordPress MU Blogs

We have recently started using WordPress MU to manage several blogs related to the products, technologies and practices on which we provide training.  I was looking for an easy way to link these blogs to each other in the sidebar without managing the links separately in each blog.

I found the easiest way was to modify the source code in the theme.  Here’s the solution I came up with:

  1. Open /wpmu/[version]/wp-content/themes/[your_theme]/sidebar.php in your editor.
    1. [version] = your version of WordPress (e.g, 2.9.2)
    2. [your_theme] = the them your using (e.g, coogee)
  2. Search for wp_list_bookmarks();
  3. Add the following code beneath that line:
    global $blog_id;
    if ($blog_id != 1)
    {
    	global $switched;
    	switch_to_blog(1);
    	wp_list_bookmarks();
    	restore_current_blog();
    }

The Result

Each blog will show their own links (i.e, the ones you add in via their specific admin pages) followed by the links added to the main blog ($blog_id==1).

The only downside I see is that this doesn’t allow for links specific to your main blog. I expect it wouldn’t be hard to modify the code to only list bookmarks from a certain category though. Anyone want to take a stab at that?

Get the latest updates on our blog, classes, and tutorials by subscribing to our free newsletter. Click here to sign up.