Debunk 4 Myths About WordPress Shortcodes

There is a big chance when you write new content for your website that you will repeatedly use the same code to insert needed functionality in particular pages.

Often you repeat the same HTML and CSS code on a daily basis and the task becomes tedious and error-prone.

The way you can avoid this problem is by using shortcodes. They are a WordPress features, which allows you to call useful pieces of code regularly, and in the same time lower the chance of making errors.

WordPress shortcodes allow you to cut down on repetitive HTML strings and insert them wherever you require them. For example, you can make a shortcode that displays a Google AdSense ad or inserts a call to action button.

But what do these look like?

Shorcodes are descriptive and inserted into square brackets. One such example is [adsense] – a shortcode used to visualize a block of ads from Google.

There are, however, some myths in circulation that surround WordPress shortcodes, and I will attempt to debunk them. These are as follows:

1. WordPress shortcodes do not save you time.

Examine the following line of code I have made to serve the needs of one of my clients:

WordPress shortcodes

If my client wants to use the code, he would have to remember to both wrap the button in a span tag and assign a class to a link.

Take the time to consider it…

Each time my client needs to add a button, he would have to go through these two steps and remember them. This is a very tedious task for a non-technical person and it is best to avoid it.

In order to present my client with a better way of accomplishing the same task, I made a shortcode, which is both easier to use and makes more sense:

WordPress shortcodes

The aforementioned shortcode generates a button with the “Go to Yahoo” code and links to Yahoo.

2. Creating shortcodes is a difficult and time-consuming task.

WordPress allows you to create shortcuts in an easy way. Let us, for example, discuss how we can implement the [adsense] shortcode into our own code. We should first define a function for the actual code of Adsense. The code below could be added to the function.php file of your theme or a plugin file:

WordPress shortcodes

This pretty straightforward function only serves to return a string of my Google Adsense code. My shortcode will be replaced with whatever this function returns. Instead of Google Adsense code, I could have as easily returned the html for a Facebook widget or anything else with the same function.

After creating a function that outputs what we need, we should hook that to a shortcode. It is where the WordPress API comes to our aid. Let us examine more closely how we can do it and explain the mechanism behind it. The call to set up this particular Adsense shortcode would look like this:

add_shortcode(‘adsense’, ‘get_adsense’);

That is all we need to do! The above function’s first parameter is the name of the shortcode we created (adsense). It instructs WordPress to create the shortcode [adsense] using the results of our function get_adsense.

It isn’t too bad? Is it? By employing simple shortcodes, WordPress grants us the option to do so much more, even to add parameters.

Now it is time to use the shortcode. It should be added either in the Visual or HTML views of a WordPress post or page. That is all that has to be done. You have easily created your first shortcode.

3. Shortcodes are hard to edit and don’t make much of a difference.

In just a few words, a shortcode will allow you to have access to whatever kind of functionality it has. It could range from the very simple task of inserting an icon and altering the color of a particular text to inserting an image gallery of images that slide on the page, creating an astonishing experience for the user.

A strong example of how the use of shortcodes can make big difference is when someone creates page layouts. Nowadays it is very common to stumble upon a full-width page layout having text paragraphs spanning throughout the page’s entire width that screams in the face of whoever has just discovered it “I AM JUST ANOTHER LARGE PIECE OF UNREADABLE CONTENT!”

With good number of decently set layout-type shortcodes, the author could have sorted the problem easily. In fact, there is no reason for him not to do so. Why not to narrow the columns a bit with a shortcode? Why not reduce the impact of all that text by inserting accordions and a few tabs, for example? It is even possible to add a number of images in a gallery or slider to ensure the page is more appealing to the reader.

4. All shortcodes must be created in advance.

Actually, it is possible that your current theme already has built in shortcodes. In order to determine which shortcodes your particular theme has, you need to open your theme’s documentation and read through it. Some themes even have demos that list all the shortcodes you can apply using them. Another alternative is to search for a bundled shortcode plugin, and these can be both free and premium.

If you are interested in creating your own shortcodes, the Shortcode API Codex of is a good place to start from.

The WordPress shortcodes have a lot of untapped potential. They are very helpful at allowing WordPress users to insert complex content areas, even though they have no technical background, with ease. The same is true for those will a lot of technical knowledge. They find WordPress shortcodes very beneficial for better managing duplicate content areas. The use of WordPress shortcode makes the management of a website easier.

Leave A Comment

WordPress Anti Spam by WP-SpamShield

Stay Friends


Want all Free Resources?