WordPress Short Code Quick Overview

By

September 24, 2012Wordpress1 Comment

WordPress shortcode is an API which replaces a given string with the output of callback function. WordPress Shortcode concept is similar to macro(preprocessor) in c programming language. Wherever the particular shortcode string is called it is replaced with the output of the handler function.

Syntax:

shortcode_string – This is the name given for shortcode_string
shortcode_handler – This is the name of the callback/handler function to be called.

Code Example:

The Above code example illustrates how to use shortcode in your custom plugin. The Above Shortcode should be wrapped within square brackets and can be placed anywhere in the site. WordPress will take care of parsing and rendering the actual output.

The shortcode format for the above string looks as show below.

Prints “Welcome to WordPress” Message dynamically. we can also pass arguments in the shortcode.

Some of the plugins that makes use of this feature include

 

  • contact form 7
  • snazzy archives etc

Example from contact form7 plugin:

 

One Response to “WordPress Short Code Quick Overview”
  1. mydons says:

    @mydons:disqus : This is good tip.

Leave a Reply