WordPress Quicky: Use the [Shortcode] API

Another quicktipp for wordpress plugin developers. With the shortcode API you can easily provide additional commands for wordpress authors …

A short code is a command that can be used in the post text. You can recognize a shortcode by the surrounding square brackets, like: [example] … a shortcode can also handle parameters: [example param="very cute"]

The short code API helps you with finding, parsing and handling such codes:

 
function handleSimpleShorttag($atts) {
	extract(shortcode_atts(array(
		'really' => '',
	), $atts));
	if ($really) {
		return "It's really simple!";
	}
	return "Is's simple!";
}
add_shortcode('simple', 'handleSimpleShorttag');

… you can add shortcodes in a plugin or simply in the functions.php of your theme.

Tags: , , , , , ,