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

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…..

 

3 Responses

  1. sasha says:

    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?

  2. […] Check out how you can use the shortcode on your Theme file […]

  3. […] Check out how you can use the shortcode on your Theme file […]

Leave a Reply

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