Created a Plugin to Add List Links Shortcode

A bit neglected thing is the Links manager feature of WordPress. I have been wanting to use it to manage lists of cool stuff I find. I was thinking, there needs to be a different thing that’s not exactly a page (a theoretically “permanent” page of stuff), or a post (a very time-dependent grouping of simple ideas)–it is like a list of really related stuff that you need to know about.

The links manager I thought could work quite nicely for this, and if you created a shortcode, it could call that. I created a plugin, that I think should be well self-contained. It needs no interface, it just activates the shortcode. You could use this same framework for any number of other shortcodes as well. Having them as plugins is handy, in that it’s atomic–easily exchangeable between themes, projects, etc.

You can pass any of the arguments to the shortcode that you would pass to the wp_list_bookmarks() function. That makes it quite flexible. (Has anyone else done this? Is this just built into WordPress, and I didn’t notice? I don’t think so. The shortcode thing is relatively new.)

The Links feature lets you have link categories, descriptions, URLs (obviously), and even all kinds of fancy stuff like XFN data and images and ratings and stuff, if you want.

Here’s an example shortcode:

[[list-links exclude_category=’2′ show_description=’1′ between=’ – ‘]]

Obviously then you could style this with CSS. The shortcode API (see link above) gives you lots of options about how you want to output things, and you could easily insert ids or classes for this styling.

Here’s the code of my plugin:

[sourcecode language=”php”]
function list_links_handler($args, $content=null, $code="") {
wp_list_bookmarks( $args );
}
add_shortcode(”, ‘list_links_handler’);
[/sourcecode]

It’s really simple. It’s just a wrapper. Maybe it’s already out there somewhere, I don’t know. Very handy, though.

Posted in

Chris