
Add a Links Page to your WordPress Template
We were working on a client site today to add an iPad Cover Review list to the site. Rather than listing them all out in a page or a post, we decided to build a template page that pulled one link category from WordPress’ build in Links section, called “Reviews”.
The WordPress API already has a built in function, called wp_list_bookmarks, that formats the bookmarks out in an unordered list format. The problem is that you can’t add a target to the anchor tag to make the links open in a new tab or window. So… you need to write your own loop to make that happen. You can do this with the get_bookmarks function.
First, I’m going to capture the links into an array and order them ascending, by name, directly from the Reviews link category. Then I output the HTML to produce the list:
<ul><?php $links = get_bookmarks( array( 'orderby' => 'name', 'order' => 'ASC', 'category_name' => 'Reviews' )); // Loop through each bookmark and display the formatted output foreach ( $links as $link ) { echo '<li><a href="'.$link->link_url.'" target="_blank">'; echo $link->link_name.'</a> – '; echo $link->link_description; echo '</li>'; } ?></ul>
Now you can generate the list however you would like with whatever styling you’d like. We’ve taken it to the extreme on our corporate site for reviewing our client list, where we also integrated live thumbnail images of the sites. You can even add a nofollow tag.