Bookmark (aka: Link) Shortcode

I wanted to use the built in WordPress admin link manager (now referred to as bookmarks) on a big site where links (especially external links) may occasionally change and be referred to in many places. Now I can manage my links in one place and by placing this snippet of code in the functions.php file I can use a shortcode to bring up any link by it's id.


	// Add Bookmark shortcode

	// Usage: [bookmark linkid=8]
	// Returns: <a title="Extreme Web Design" href="" target="_blank">Extreme Web Design</a>

	function bookmark_shortcode($atts, $content = null) {
			'linkid' => '0'
		), $atts));
		$bookmark = get_bookmark($linkid);
		return '<a title="' . $bookmark->link_description . '" href="' . $bookmark->link_url . '" target="' . $bookmark->link_target . '">' . $bookmark->link_name . '</a>';
	add_shortcode("bookmark", "bookmark_shortcode");