How to use shortcodes in your template file (WordPress Tips)

We are very familiar in using shortcodes for adding things to wordpress. Many themes are now coming with shortcode feature which can be used in post & pages. But in some cases we need to use the shortcode in our template file like if we wanna show in the footer or header or any other..

However, Here I’ll show you how to use shortcode in WordPress template file. Nothing complicated, just need to add small piece of code :

<?php echo do_shortcode('shortcode'); ?>

Use the above code anywhere in your template file where you want the shortcode to work/function.. Replace the (‘shortcode’) text with your shortcode.

Thanks for reading this & enjoy…..

Published by

Abdul Awal

Hi, This is Abdul Awal. I am Web Developer working as a freelancer for about 3 Years now. You may visit my personal website for more details about me. abdulawal.com

3 thoughts on “How to use shortcodes in your template file (WordPress Tips)”

  1. I just want to tell you that I am newbie to blogging and definitely liked your blog. Probably I’m want to bookmark your blog . You really come with good article content. Cheers for sharing with us your blog.

  2. Hi there! I am new to shortcode and I need to simply display post counts by a user. What should I do to get this placed into a custom wordpress page that I have created?

Leave a Reply

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