Creating a self-closing shortcode with parameters
<?php
function button_shortcode( $type ) {
extract( shortcode_atts(
array(
'type' => 'value'
), $type ) );
// check what type user entered
switch ($type) {
case 'twitter':
return '<a href="http://twitter.com/rupomkhondaker" class="twitter-button">Follw me on Twitter!</a>';
break;
case 'rss':
return '<a href="http://example.com/rss" class="rss-button">Subscribe to the feed!</a>'
break;
}
}
add_shortcode( 'button', 'button_shortcode' );
?>
Now you can choose what button to display by defining type in your shortcode.
[button type="twitter"]
[button type="rss"]