Shortcodes are great tools for creating complex content in the WordPress post editor without having to resort to tags or other complex mechanisms. Since you control the exact output when using a shortcode, you can easily blend shortcodes into any project or create hooks to let others do the same.
In this article, we’ll look at how the Shortcode API works by creating some handy shortcodes ourselves to help save time when writing posts.
The basic building block is the add_shortcode() function through which you define a keyword and a function which will handle the shortcode output. The first parameter will be parsed for in the editor and any matches will be converted to the output specified by the function defined in the second parameter.