WordPress has a built-in links manager.  It was basically intended to be used for what was and still is referred to as a blogroll.  Blogrolls aren’t quite as popular today but don’t let this feature go to waste.  If you have been thinking about adding a page of links you want to direct your users to, or feature a small links directory, here’s how to do it without adding a plugin.

In a new install of WordPress you might not see the links manager in the admin page menu because starting with version 3.5 WordPress disabled this feature.  There are many other sites out there with instructions on how to enable it but I’ll save you the searching and add that here.

To do what we want to do you need to be comfortable with editing your theme functions.php file.  If you aren’t, to quote a scene from Monty Python’s Holy Grail, “Run away! Run away!”.

Enable The Links Manger
Add the following to your WordPress functions.php file:

add_filter( 'pre_option_link_manager_enabled', '__return_true' );


Set Up A Links Page
Still editing your theme functions.php file, we will now add a new function that will create a shortcode to generate a links page using the links you have in your links manager.  Add this to the functions.php file:

// Shortcode :: Display Links //
function c3showlinks_shortcode($atts) {
    echo '<ul class="links">';
    echo wp_list_bookmarks('categorize=1&hide_invisible=1&show_description=1');
    echo '</ul>';
add_shortcode('c3showlinks', 'c3showlinks_shortcode');

The shortcode we’re creating here is called “c3showlinks”.  You can of course name this what ever you would like as long as you follow through with the new name.

Next, create a new page on your WordPress site.  Let’s just title it “Links” and in the page content window simply place nothing but this shortcode:


Now save your new Links page and take a look.  Of course you’ll want to add some categories and links in the link manager.  You’ll probably want to add some CSS styling as well.  The new shortcode function assigns the class “links” to the result.  So in your stylesheet you could add something like this:

.postentry ul.links {
	list-style-type: none;
	margin-left: 0;
	padding-left: 20px;

The above style sets the margin, padding, and removes the marker before each category name.  Additional styling helps refine further the font size and weight for the category name using

.linkcat h2 {}

To set the style for the links use

.blogroll li {}

In both instances above the class is automatically set by WordPress.

There are many options you can call in the wp_list_bookmarks() function to further stylize your list of links.  Refer to the WordPress function reference for more info on that.

And there you have it.  Simple and no additional plugins required.  Hopefully this has given you some ideas on expanding your WordPress site with some built-in and little used functionality.

Follow comments on this post with this RSS 2.0 feed.
Leave a comment, or trackback from your own site.

You must be logged in to post a comment.

. . :   design & hosting by creed3.com   : . .