Just finished reading Smashing Magazine’s article on Wordpress shortcodes and it’s loaded (yet again) with the good stuff!

Shortcodes are those little bracket enclosed functions we can include in our blog posts and they magically seem to give our posts a lot more functionality.

Well it’s not magic and you could make your own! Fire up your CPanel or host directory and find your theme’s functions.php and try the venerable Hello World:

//Let's define our Hello World code here:
function hello() {
    return 'Hello, World!';
}
//Add the Hello World to the functions list
add_shortcode('hw', 'hello');


Then add the following to your blog post!

[hw]

More shortcodes!

For the picky bloggers who want more control of their “tweet this” plugs, you can also try the following shortcode for your very own “Tweet This” within your blog post:

//You can style the link by creating a CSS style rule that matches the div id or class :P
function twitt() {
    return '


';
}
add_shortcode('twitter', 'twitt');

Insert your now functional short code into your post draft:


Trying the twitter shortcode below:

Enjoy the shortcodes but just be careful not to create infinite loops!

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • email
  • Ping.fm
  • Reddit
  • StumbleUpon
  • Technorati
  • Tumblr
  • TwitThis
  • Yahoo! Buzz
  • Live