WordPress Links Page

Today I was playing around with the blog, and decided that the Blogroll I have up needed some improvement. Unfortunately I couldn’t find anything on the Internet that did what I wanted (ie the lazy way failed), so I had to dig into the theme files for WordPress and make something up myself.

After doing a bit of research, I found out two handy things. The first is that WordPress supports Page Templates, which is a fancy way of describing how a page looks. Static pages (About Me, Contact Details, etc) have one template, and posts (the main blog content) have another. They are similar templates, but not identical. The second handy thing I discovered is the internal WordPress function wp_link_bookmarks(). Putting these two pieces of information together, I decided the easiest thing to do was create a ‘Links Page’ template, and then use this template for an empty page. The wp_link_bookmarks() function would dynamically generate my blogroll on each page view.

I had to play around a bit with the parameters to wp_link_bookmarks() quite a bit in order to get it to display properly; the function kept insisting on placing bullets on the category names as well.

You can download the page template file from here, if you wish. It should work with most WordPress themes (if it doesn’t let, me know). To use it:

  1. Upload the links.php file to your WordPress installation, in
    /wp-content/themes/<theme-name>/
  2. Create an empty static page in WordPress, give it a name (Blogroll or Links Page or whatever), and disable comments (the template won’t look pretty with comments enabled).
  3. On the right-hand side of the page editor, use the ‘Page Template’ option and set it to ‘Links Page’.
  4. Publish the page. Enjoy.

Tags: , , ,

Leave a Reply