I was recently working on my new blog, and I came across a shortcode I could use to display some content on the blog, but the problem I faced was using the shortcode in my theme file since shortcodes are special tags that you can enter into a post that gets replaced with different content when actually viewing the post on the website.

I made my research found the php function code that could easily help you echo a shortcode in a WordPress PHP theme file and decided to share it with you.

The WordPress do_shortcode() function is all you need to work this out.

Simply add the shortcode in this format.

<?php echo do_shortcode( ‘your-shortcode‘ ); ?>

All you need do is replace the blue text your-shortcode with the exact shortcode text you want to use on your blog’s theme file.

Hurray! You’ve successfully displayed your wordpress shortcode in your wordpress theme file.

 

11 COMMENTS

  1. I don’t quite get this. Anyway, I don’t know much about coding but I think you should explain further so that your readers can fully understand this post.

LEAVE A REPLY

Please enter your comment!
Please enter your name here