The simplest shortcode is the self-closing one. We’re going to create a simple link to our Twitter account, and then add it in a blog post.
All the code goes in functions.php
, which is located in /wp-content/themes/your-theme/
. If you don’t have one, just create it and put the code in it.
<?php
function button_shortcode() {
return '<a href="http://twitter.com/rupomkhondaker" class="twitter-button">Follow me on Twitter!</a>"';
}
add_shortcode('button', 'button_shortcode');
?>
Usage: [button]