How To Add A Shortcode In WordPress (Quick Guide)

How_to_Add_A_Shortcode_In_WordPress

Adding dynamic contents in your WordPress posts/pages is very easy if you consider to add a shortcode. All you have to do is place code inside your page/post, and your dynamic content will be ready. 

There are many themes and plugins in WordPress that use shortcodes to add galleries, sliders, contact forms, and more. Using shortcode is very easy, in this article I will show you how to add your own shortcode in WordPress

But before add a shortcode, it is essential to know about shortcodes. 

What Is ShortCode?

In short, shortcodes are more like code shortcuts. For saving time of repeated works, shortcode is used. Shortcodes help you to add dynamic content in WordPress pages, posts, widgets, etc. Shortcodes are wroten inside square brackets like

[shortcode]

WordPress filters all contents of your pages and posts, then make sure so that no one can insert any malicious code in the database. That means you cannot write any PHP code except basic HTML in your post/pages.

What if you want to run some custom codes inside your post to display ads, contact forms, galleries, related posts, etc.?

Well, for this reason, shortcodes are born. Shortcode allows developers to add their desired code in a function and then register it with WordPress as a shortcode. Therefore, users can easily use it without having any prior coding knowledge. 

When WordPress finds any shortcode, it automatically runs the code associated with it. 

Now, let’s check out how to add a shortcode in WordPress. 

How To Add A Shortcode In WordPress Post/Page

To add a shortcode to your WordPress post/page, you need to have a plugin that works with shortcodes. There are a lot of plugins that work with shortcodes, like WP Table Builder, Contact Form 7, WP Call button, OptinMonster, etc. 

After you install any plugin that will provide you a shortcode, copy the code. 

Create a new post/page or edit the existing one, in which you want to add a shortcode. Now click on the add block (+) button and insert a shortcode block. 

Type ‘shortcode’ in the search bar and shortcode block will appear. After adding the shortcode block, paste the shortcode in the block. 

Now save the post/page and preview the changes that shortcode has brought. 

How To Add Shortcode In WordPress Widget

Shortcodes also work great with WordPress widgets. To add a shortcode in WordPress widget, go to Appearance -> Widgets page. 

Add a ‘Text’ Widget by dragging it from the left side. Now paste your shortcode in the text field of the widget and click the ‘Save’ button. 

Now visit your WordPress site and check the changes live. 

Final Words

I hope you have learned how to add a shortcode in WordPress with the help of this post. If you like this post, please consider sharing the post.

Don’t forget to share your thoughts, and I will be happy to reply to you.

Leave a Comment

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

Copy link
Powered by Social Snap