WordPress undoubtedly is the most popular blogging software. Professional bloggers using WordPress must have knowingly or unknowingly used shortcodes to ease their work.

What is a Shortcode?

A shortcode is a small pre programmed function inside a plugin or inside a core file (usually the theme’s functions.php file) which is used to display a particular information into a page or post easily and effortlessly.

Shortcode inside Shortcode in WordPress

Shortcode inside Shortcode in WordPress

Inside an article, a shortcode is written in square brackets. Notice the warning message displayed at the bottom of this article. This is displayed using the following shortcode :

[warning]The Blah Blah Warning Message[/warning]

Shortcode inside Shortcode in WordPress

By default, WordPress does not allow a shortcode to be used inside a shortcode. We need it often to use a shortcode inside a shortcode. In that case we need to modify core files to be able to do this.

We will call the outside shortcode as parent-shortcode and that nested inside it as child-shortcode. We’ll have to modify the defining function of the parent-shortcode.

First of all we need to locate the file which contains the defining function of the parent-shortcode. It is not a difficult task. You can spot the function with the name of the parent-shortcode. If the shortcode is defined by an external plugin, then you should see inside the core files of the plugin which can be found at the wp-content/plugins folder. If it is a self-defined shortcode then you will have to find the file where you have defined the parent-shortcode. It is usually the theme’s functions.php file.

Now you have located the file, you should look for the defining function of the parent-shortcode written inside this file.

Inside this function just replace

That’s all. You don’t need to modify the child-shortcode. Now you can use a shortcode inside the parent-shortcode.

You should understand that editing core files in wrong way can prove fatal for your website. Make a backup copy of the files before modifying them, so that you can restore them back to the normal if anything goes wrong. Use this tutorial at your own risk.