WordPress / Web Development Tutorials
(Best WordPress Tutorials)

Silva Web Designs - Blog

How to create a WordPress Shortcode

The shortcode API allows you to create your own shortcodes by adding functions to your theme functions.php template (this can be found; www.your-site.co.uk/wp-content/themes/yourtheme/).

Let’s get straight to the point and start with a basic shortcode function.

Please remember that shortcodes should be created for content and functionality that you use frequently. The whole point of using shortcodes is to save someone time. If you are only going to use something once, there is not much point in creating a shortcode for it.

Let’s create a very simple shortcode that will display today’s date, to do this I would start by adding a function such as this to my theme’s functions.php template:

// Add Shortcode
function shortcode_todays_date() {

// Code
$widget_content  = "Today is " . date("d/m/Y");
return $widget_content;
add_shortcode( 'todays_date', 'shortcode_todays_date' );

Those of you who have no coding experience may find the above code a little daunting, however it is easy to understand once you break the code down line by line.

Even if you have no experience you can go to this website to generate the shortcode code for you.

After saving the functions.php template, we can now call our message whenever we want using the shortcode todays_date.


The above will output Today is DD/MM/YYYY.

It’s as simple as that, I hope this has helped you.


Nathan da Silva - Profile

Posted by: Nathan da Silva

Nathan is the Founder of Silva Web Designs. He is passionate about web development, website design and basically anything digital related. His main expertise is with WordPress, Magento, Shopify as well as many other frameworks. Whether you need responsive design, SEO, speed optimisation or anything else in the world of digital then get in touch. If you would like to work with Nathan, simply drop him an email at [email protected]

It’s good to share

Join the discussion

Related Posts

Related - How to Hide / Disable the WordPress Admin Bar

Wordpress / 22nd January 2021

How to Hide / Disable the WordPress Admin Bar

Read More Related - How to Completely Remove Comments From a WordPress Site

Wordpress / 22nd December 2020

How to Completely Remove Comments From a WordPress Site

Read More