DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

Shortcodes have been introduced in WordPress 2.5. They’re hooks which allow you to call a php function simply by typing something like [shortcode]. It is a great way to save time on repetitive tasks. Just read on to find out how to use them.

To create a shortcode, you first have to create a php function. Let’s start with a basic one. Append it to your functions.php file.

function wprecipes() {
    return 'Have you checked out <a href="http://www.wprecipes.com">WpRecipes</a> today?';

Once you created your function, you have to use the add_shortcode() function. paste this code just after your function on the functions.php file from your theme:

add_shortcode('wpr', 'wprecipes');

You’re now able to use the wpr shortcode. To do so, paste the following line of code on the editor (in HTML mode) while writing a post:


This short code will output the “Have you checked out WpRecipes today?” message.


  1. Hi, I had a shortcodes placed in my title of my wp article post for seo results, i.e. {city} using a wp plugin. It is suppose to get indexed in Google, Yahoo, Bing, etc.

    I am not sure whether to include “the title with the shortcode {city}”, or just leave the {city} by itself in the article post without the title in order for them to show the {city} i.e. New York without the {}?

    I hope this make sense to you?

  2. Thanks for these short codes! They saved my lot of time 🙂

Leave a Comment

Your email address will not be published. Required fields are marked *