Skip to content

SALE - Get Flat 20% OFF on Theme Bundle of 120+ Premium Themes Just at $89

Get Bundle!!

FLASH SALE - Get 25% Discount on All Themes, use code "FLASH25"

  • Home
  • About Us
  • Themes
  • Support
  • Contact
  • Blogs
Log in

Country/region

  • Afghanistan USD $
  • Åland Islands USD $
  • Albania USD $
  • Algeria USD $
  • Andorra USD $
  • Angola USD $
  • Anguilla USD $
  • Antigua & Barbuda USD $
  • Argentina USD $
  • Armenia USD $
  • Aruba USD $
  • Ascension Island USD $
  • Australia USD $
  • Austria USD $
  • Azerbaijan USD $
  • Bahamas USD $
  • Bahrain USD $
  • Bangladesh USD $
  • Barbados USD $
  • Belarus USD $
  • Belgium USD $
  • Belize USD $
  • Benin USD $
  • Bermuda USD $
  • Bhutan USD $
  • Bolivia USD $
  • Bosnia & Herzegovina USD $
  • Botswana USD $
  • Brazil USD $
  • British Indian Ocean Territory USD $
  • British Virgin Islands USD $
  • Brunei USD $
  • Bulgaria USD $
  • Burkina Faso USD $
  • Burundi USD $
  • Cambodia USD $
  • Cameroon USD $
  • Canada USD $
  • Cape Verde USD $
  • Caribbean Netherlands USD $
  • Cayman Islands USD $
  • Central African Republic USD $
  • Chad USD $
  • Chile USD $
  • China USD $
  • Christmas Island USD $
  • Cocos (Keeling) Islands USD $
  • Colombia USD $
  • Comoros USD $
  • Congo - Brazzaville USD $
  • Congo - Kinshasa USD $
  • Cook Islands USD $
  • Costa Rica USD $
  • Côte d’Ivoire USD $
  • Croatia USD $
  • Curaçao USD $
  • Cyprus USD $
  • Czechia USD $
  • Denmark USD $
  • Djibouti USD $
  • Dominica USD $
  • Dominican Republic USD $
  • Ecuador USD $
  • Egypt USD $
  • El Salvador USD $
  • Equatorial Guinea USD $
  • Eritrea USD $
  • Estonia USD $
  • Eswatini USD $
  • Ethiopia USD $
  • Falkland Islands USD $
  • Faroe Islands USD $
  • Fiji USD $
  • Finland USD $
  • France USD $
  • French Guiana USD $
  • French Polynesia USD $
  • French Southern Territories USD $
  • Gabon USD $
  • Gambia USD $
  • Georgia USD $
  • Germany USD $
  • Ghana USD $
  • Gibraltar USD $
  • Greece USD $
  • Greenland USD $
  • Grenada USD $
  • Guadeloupe USD $
  • Guatemala USD $
  • Guernsey USD $
  • Guinea USD $
  • Guinea-Bissau USD $
  • Guyana USD $
  • Haiti USD $
  • Honduras USD $
  • Hong Kong SAR USD $
  • Hungary USD $
  • Iceland USD $
  • India USD $
  • Indonesia USD $
  • Iraq USD $
  • Ireland USD $
  • Isle of Man USD $
  • Israel USD $
  • Italy USD $
  • Jamaica USD $
  • Japan USD $
  • Jersey USD $
  • Jordan USD $
  • Kazakhstan USD $
  • Kenya USD $
  • Kiribati USD $
  • Kosovo USD $
  • Kuwait USD $
  • Kyrgyzstan USD $
  • Laos USD $
  • Latvia USD $
  • Lebanon USD $
  • Lesotho USD $
  • Liberia USD $
  • Libya USD $
  • Liechtenstein USD $
  • Lithuania USD $
  • Luxembourg USD $
  • Macao SAR USD $
  • Madagascar USD $
  • Malawi USD $
  • Malaysia USD $
  • Maldives USD $
  • Mali USD $
  • Malta USD $
  • Martinique USD $
  • Mauritania USD $
  • Mauritius USD $
  • Mayotte USD $
  • Mexico USD $
  • Moldova USD $
  • Monaco USD $
  • Mongolia USD $
  • Montenegro USD $
  • Montserrat USD $
  • Morocco USD $
  • Mozambique USD $
  • Myanmar (Burma) USD $
  • Namibia USD $
  • Nauru USD $
  • Nepal USD $
  • Netherlands USD $
  • New Caledonia USD $
  • New Zealand USD $
  • Nicaragua USD $
  • Niger USD $
  • Nigeria USD $
  • Niue USD $
  • Norfolk Island USD $
  • North Macedonia USD $
  • Norway USD $
  • Oman USD $
  • Pakistan USD $
  • Palestinian Territories USD $
  • Panama USD $
  • Papua New Guinea USD $
  • Paraguay USD $
  • Peru USD $
  • Philippines USD $
  • Pitcairn Islands USD $
  • Poland USD $
  • Portugal USD $
  • Qatar USD $
  • Réunion USD $
  • Romania USD $
  • Russia USD $
  • Rwanda USD $
  • Samoa USD $
  • San Marino USD $
  • São Tomé & Príncipe USD $
  • Saudi Arabia USD $
  • Senegal USD $
  • Serbia USD $
  • Seychelles USD $
  • Sierra Leone USD $
  • Singapore USD $
  • Sint Maarten USD $
  • Slovakia USD $
  • Slovenia USD $
  • Solomon Islands USD $
  • Somalia USD $
  • South Africa USD $
  • South Georgia & South Sandwich Islands USD $
  • South Korea USD $
  • South Sudan USD $
  • Spain USD $
  • Sri Lanka USD $
  • St. Barthélemy USD $
  • St. Helena USD $
  • St. Kitts & Nevis USD $
  • St. Lucia USD $
  • St. Martin USD $
  • St. Pierre & Miquelon USD $
  • St. Vincent & Grenadines USD $
  • Sudan USD $
  • Suriname USD $
  • Svalbard & Jan Mayen USD $
  • Sweden USD $
  • Switzerland USD $
  • Taiwan USD $
  • Tajikistan USD $
  • Tanzania USD $
  • Thailand USD $
  • Timor-Leste USD $
  • Togo USD $
  • Tokelau USD $
  • Tonga USD $
  • Trinidad & Tobago USD $
  • Tristan da Cunha USD $
  • Tunisia USD $
  • Türkiye USD $
  • Turkmenistan USD $
  • Turks & Caicos Islands USD $
  • Tuvalu USD $
  • U.S. Outlying Islands USD $
  • Uganda USD $
  • Ukraine USD $
  • United Arab Emirates USD $
  • United Kingdom USD $
  • United States USD $
  • Uruguay USD $
  • Uzbekistan USD $
  • Vanuatu USD $
  • Vatican City USD $
  • Venezuela USD $
  • Vietnam USD $
  • Wallis & Futuna USD $
  • Western Sahara USD $
  • Yemen USD $
  • Zambia USD $
  • Zimbabwe USD $
  • Facebook
  • Pinterest
  • Instagram
THEMESPRIDE
  • Home
  • About Us
  • Themes
  • Support
  • Contact
  • Blogs
Log in Cart My Account

A Custom Guide to Add Shortcodes in WordPress

August 11, 2023
A Custom Guide to Add Shortcodes in WordPress
Share

Add Shortcode in WordPress: Struggling with how to add shortcodes to the WordPress website? Keep this article pinned on your device as you will get the vital answers on this.

Shortcodes are shortcut codes that when added to the website allow the addition of dynamic content. It can be easily added to WordPress posts, pages, and other locations. This comes in a single line enclosed in square brackets to generate any content. In short, users are allowed to add a custom code to the function and then run that function using a shortcode. This is a great way for non-developers to use shortcodes even without any technical knowledge.

Though, WordPress has made it far easier to add dynamic content without using codes. Still, some parts of the website like banner ads and galleries can't work without a shortcode. So if you are one of those who wish to add shortcodes, can refer to the below article.

Creating a Custom Shortcode in WordPress

Ready to build your first custom shortcode in WordPress? Let’s get started.
Shortcodes can work as a vital supplement for your website when in need to add dynamic content. You can simply add some shortcodes that result in nifty results for your website. So, here’s how you can create a custom shortcode in WordPress:
This guide is a clear chit for those skilled in coding languages like PHP. We are going to use PHP code that can be used as a sample template.
Here, we are creating a function running the code and returning the output. After this, another shortcode will be created named “Greetings” that will run the function.

// function that runs when the shortcode is called
function wpb_demo_shortcode() {
// Things that you want to do.
$message = 'Hello world!';
// Output needs to be return
return $message;
}
// register shortcode
add_shortcode('greeting', 'wpb_demo_shortcode');

This will further help in inserting the shortcode into any part of the website using the below shortcode:

This will ultimately generate the desired output for the function you created.

  • Adding Shortcodes in Different Areas of WordPress Website
  • Adding Shortcodes in WordPress Posts and Pages
  • Adding Shortcodes in Sidebar widgets
  • Adding Shortcodes in Old Classic Editor
  • Adding Shortcodes in WordPress Theme Files
  • Adding Shortcodes in WordPress Templates

Adding Shortcodes in WordPress Posts and Pages

  • Now that you know how to create a custom shortcode, let’s move ahead to add shortcodes to pages and posts. To add shortcodes in posts and pages, follow the given steps:
  • On your WordPress dashboard, tap the posts or pages option. We are going to edit the page by clicking on it.
  • Next, you will reach the list of pages you have created previously. You need to tap the Edit link under the page you wish to edit.
  • This will take you to the page editor and then tap the “+” icon to explore the blocks.
  • Simply search for the shortcode block and tap to insert it on the page.
  • Once the block is inserted, enter the previously created shortcode and tap the Save Changes button.
  • You can now be able to watch out for the results after inserting the shortcode.

 

Adding Shortcodes in WordPress Sidebar Widgets

  • Just like the posts and pages, you can add shortcodes in the sidebar widgets as well. And here's the perfect guide on this:
  • Visit the WordPress dashboard and then on the Appearance tab.
  • Choose the Widgets option among various options under the Appearance tab.
  • This will take you to the Widgets page and then tap the “+” icon to explore the widgets blocks.
  • Here, you need to search the Shortcode block and tap to insert.
  • Simply add the shortcode we generated earlier and tap the Update button at the top right corner.
  • Head back to the website and see the live changes of the widgets after entering the shortcode.

Adding Shortcodes in WordPress Old Classic Editor

This one is for those who still choose to use the old classic editor for their website editing purposes. And here’s how you can add shortcodes to the posts or pages using the old classic editor:

  • Here, we are going to edit the previously created post on your website.
  • On your WordPress dashboard, pick to click the Post option.
  • And now, you need to tap the Edit link under the post you have chosen to edit.
  • On the edit screen, simply paste the shortcode where you wish to be displayed.
  • Lastly, tap the Save Changes button to store the new changes.

Adding Shortcodes in WordPress Theme Files

We have previously added shortcodes in WordPress posts, pages, and sidebars. Surprisingly, WordPress allows the addition of shortcodes in its theme files as well.
And those with coding skills will find it easy to edit WordPress theme files and add a shortcode.
Here’s an example as we are adding the below line of code in the WordPress theme template:

Here, you must add the shortcode generated in place of “your_shortcode”. This will further give the desired result.

Which is better: Adding Shortcodes or Gutenberg Blocks?

  • The question has been a hot topic to discuss since the launch of the Gutenberg editor. Earlier, users only relied on the shortcodes and the classic editor.
  • The newly launched Gutenberg editor comes with intuitive blocks that seem to be more user-friendly.
  • While the shortcodes and the blocks result in the same output. But as of latest technology approaches, users find Gutenberg blocks easier.
  • The shortcodes can be a good game for the coding person only. But the Gutenberg Blocks can be easily used by a non-technical person as well.
  • Users find it so easy to add dynamic content using the Gutenberg blocks within a couple of times. Even a lot of WordPress plugins are adapting to the Gutenberg Blocks instead of the shortcodes.

Conclusion

So, have you got the right answers to all your queries related to Adding Shortcodes in WordPress? We have made it so easy to understand by adding shortcodes. Shortcodes can be a great way to add dynamic content to your website. And so, the above content will help you refer to the best details about adding shortcodes in WordPress.

Back to blog

Search

Blog Categories

  • Blog

WordPress Theme Bundle

Bestseller Themes

Automobile
Premium NGO Organization
Car booking
Fitness Supplement
Supermarket
Travel Offer
  • Facebook
  • Instagram
  • Pinterest

WordPress Theme Bundle

Buy Now

LINKS

  • Best WordPress Themes
  • Support
  • Contact
  • Terms and Conditions
  • Privacy Policy
  • Return
  • Blogs
  • Free WordPress Themes
  • Tour Operator WordPress Theme
  • Auto Dealer WordPress Theme

Topics

  • Automobile
  • Business
  • Construction
  • Ecommerce
  • Education
Payment methods
  • PayPal
Copyright © 2026, All Right Reserved THEMESPRIDE
  • Choosing a selection results in a full page refresh.
  • Opens in a new window.