manipulating the wordpress links manager
As we continue in our foray as WordPress-as-CMS at the A.C. Buehler Library we’re beginning to find some interesting ways to take advantage of WordPress’ built-in tools. I recently had a request to create a page that lists databases by discipline. Simple, eh?
Well, yes as it is just a bunch of well organized links, but it’s also an issue for a couple of reasons:
- The database links are also used in a couple other places on the site
- We may add or delete databases
- The links, which are proxy links, may change at any given time.
If any of the above happens we’d have to track down each page with those links and make the appropriate edits. It could become tedious. We needed a central location to make these edits so that it makes dynamic changes across the site. WordPress already has a nice link manager, which is traditionally used for blog rolls. Although we weren’t creating a blog roll, we were in need of a central storage location of links and this did just the trick. Here are the steps I took.
Step 1: Add the Links
Really, the librarian I collaborated with did the hard work. She created the list of disciplines and decided which databases worked well with each discipline based on trends in our course pages and her knowledge of what we had to offer. At this point all I had to do was enter them into the links manager.
Each link was given a title (the database name), a URL of course (proxified), and categories (a catch-all “databases” category as well as the discipline it coordinated with). If the database was considered a secondary (not the best) option for the discipline it was given a category name with the discipline and “(alternate)” added to it.
Step 2: Create the Template
If you don’t know how WordPress themes are setup let me provide a very quick primer. Themes use a variety of PHP files (e.g. header.php, footer.php, 404.php, single.php, index.php, and page.php ) and specialized template files – still .php – that usually make small modifications to the page.php file for special circumstances.
In this case we needed to modify page.php to accept some WordPress tags that could dynamically pull in our links from the Links Manager. I organized the page in a table and used the get_bookmarks based on the category. Here’s the code for the get_bookmarks tag:
1 | <?php wp_list_bookmarks('title_li=&categorize=0&category_name=Art&category_before=<li>&category_after=</li>'); ?> |
It’s doing a couple of things:
- Don’t show the category title:
- Get the category with name of “Art”:
- Wrap the link in list item tags:
1 | title_li=&categorize=0& |
1 | category_name=Art& |
1 | category_before=<li>&category_after=</li> |
Download a sample of the template page here.
Step 3: Create and Publish the Page

The only thing left to do is create the page, choose the template, and hit publish!







This is where Drupal and CCK + Views shines. Not to mention taxonomy. One of the presentations at the next Drupal group will deal with this.
I betcha it does. In my opinion it took too long to do and too many work arounds to make it work. I just started playing with Pods (http://pods.uproot.us/) and think it could work a lot better for these situation. For CCK, do you have to do any PHP to get the data to show or do you just start a new page and pick the content from a drop down box or something similar?
Thanks for the comment, Mick!
~Kyle~