How To Call Shortcode Within a WordPress template

Most WordPress plugins and widgets offer their functionality through shortcodes. Now one of the questions many people are asking is on how to call a shortcode within a WordPress template or how to use shortcodes within a WordPress template.

So if you are one of those people who are wondering how to call shortcodes or use shortcodes within a WordPress template, I’ll have you sorted. I’m going to reveal the answer I’ve been sharing in many forums. But before then, let’s first understand what WordPress shortcodes are.

Shortcodes in WordPress

These are special tags that allow you to add a bunch of cool things to your site’s pages and posts. Some of the things you can add to your site using these shortcodes include galleries, column layouts, contact forms, buttons, social media buttons, blockquotes and much more.

Through WordPress shortcode API, you can easily create your own WordPress shortcodes and add them to pages and posts. But what if you want to use WordPress shortcodes within WordPress templates instead of within pages or posts? You can do this by adding various functions to the functions.php template. Read on to find out how you can do this.

Adding Shortcodes in the PHP template

There are several ways you can do this. The one I recommend most in various forums is through the standard WordPress do_shortcode function. This function was created specifically to accomplish this task. However, before you insert this function in the theme template, you need to add a little PHP coding prior to that.

Use this code:

<?php echo do_shortcode("[place your plugin shortcode here]"); ?>

Sometimes this shortcode may fail to work simply because of the double quotation marks in them. If this is the case, then try it out with single double quotation marks as shown below.

<?php echo do_shortcode('[place your plugin shortcode here]'); ?>
If your page is calling the shortcode template instead of its respective name, just try the code below.
<?php echo do_shortcode ('[place your plugin shortcode here]' ('name of your shortcode' ) ); ?>
For instance, if it’s the Contact Form shortcode you want to place into your theme’s template, try something like:
<?php echo do_shortcode('[CONTACT-FORM]'); ?>
If you still need help on how to call Shortcode or use shortcodes within a WordPress template or any other WordPress related questions, just feel free to let me know. I will be happy to help you.

UNLIMITED DOWNLOADS: 50+ Million Website Templates & Design Assets

All the Website Templates you need and many other design elements, are available for a monthly subscription by subscribing to Envato Elements. The subscription costs $16.50 per month and gives you unlimited access to a massive and growing library of over 50 million items that can be downloaded as often as you need (stock photos too)!

Recent Articles

How to Change WordPress Theme If It Does Not Work (No Access to wp-admin) Through phpMyAdmin

Something is wrong. Your WordPress theme has got a blank screen and you can not log in to your admin through /wp-admin/...

How to Bulk Deactivate WordPress Plugins (No Access to WP-Admin) Through phpMyAdmin

Sometimes happens that you don't have any backups of your WordPress site (ups) and after your plugins update nothing works (ups, twice!),...

Landco – Garden & Landscaping WordPress Theme [Free WordPress theme download]

Demo Download Landco – Garden & Landscaping WordPress Theme Landco – Garden & Landscaping...

Optrica – Optometrist & Eye Care WordPress Theme [Free WordPress theme download]

Demo Download Optrica – A Premium WordPress Theme for all kind of optometrist...

Qwery – Multi-Purpose Business WordPress Theme + RTL [Free WordPress theme download]

Demo Download Giant Multi-Purpose Business Elementor WordPress Theme v1.0.4 Qwery is an innovative responsive...

Get in touch

Be our first-class reader, build a community and follow us on social media!

Leave A Reply

Please enter your comment!
Please enter your name here