Knowledge Base
MilesWeb / WordPress FAQ

Discover the Steps To Use WordPress do_shortcode

Approx. read time : 2 min

You can easily extend your site’s functionality by using shortcodes. Shortcodes can be placed on any part of your website by using WordPress do_shortcode function. In this article, we will show you how to apply it. So, let’s start by understanding the basics of shortcodes!

What Exactly is Shortcode?

A snippet of code, shortcode allows you to run a function such as displaying content. For instance, if you create a slider with the help of the MetaSlider plugin, you need to embed the plugin’s shortcode into your site to show the slider.

But, you can only embed it on the site’s body or widget or else, the content won’t get displayed. For resolving this issue, you can use WordPress do_shortcode function. By using it you can embed the shortcode anywhere you want – including the header. It looks as below:

To apply this function, go to the theme files and tweak them. Ensure that you take a complete backup of your WordPress site and use the WordPress child theme in advance to avoid data loss if anything goes wrong.

Steps to Use WordPress do_shortcode

Now, let’s try to add a shortcode using WordPress do_shortcode. For instance, suppose you want to add a slider in your theme’s header using MetaSlider – ensure you’ve installed the plugin. However, there is no widget for the header area.

Therefore, you need to embed the shortcode of the slider to the theme’s header file. For this, follow the below steps:

  1. Click on MetaSlider located on the left sidebar of the WordPress admin dashboard.
  2. Go to the bottom right of the page and copy the shortcode.

If the MetaSlider’s shortcode is already present within the WordPress do_shortcode function then edit the theme’s header file by going to your hosting provider’s file manager or an FTP client like FileZilla.

The below steps will show you the steps to edit theme files with MilesWeb’s file manager – it can be applied in an FTP client as well:

  1. Hover to your cPanel and click on File Manager.
  2. Navigate to the public_html folder and move to wp-contents -> themes.
  3. Find and go to your currently active theme folder.
  4. Open header.php, then scroll down the page and add the do_shortcode function above the tag.
  5. Save and check your website appearance.

Sometimes when you edit theme core files, it can break your WordPress template. For this, you should alter the CSS to improve your website’s appearance.

Conclusion

In this way, you have learned to use shortcodes and display them using the WordPress do_shortcode function. Just add the shortcode into the theme’s file, and you’re ready to go! Remember to take the backup of your site before editing the file to avoid the risk of losing data.

If you have any questions regarding the topic, drop a comment below!

Avatar
Pallavi is a Digital Marketing Executive at MilesWeb and has an experience of over 4 years in content development. She is interested in writing engaging content on business, technology, web hosting and other topics related to information technology.

Trusted By Thousands of Clients & Big Businesses

We highly appreciate the kind and stellar feedback we receive from our customers. Delivering the best is our goal! MilesWeb is rated Excellent 4.8 out of 5 based on reviews. Read more reviews.

Excellent
Based on reviews
2 hours ago
Perfect and Valuable Server + ...
I am using MilesWeb Servers, The main thing which I getting are continuous support over everything w...
Gunjan Makwana
4 hours ago
Milesweb is superb Hosting pro...
Milesweb is superb Hosting provider ever, their Support team is amazing!!!...
Abhishek Singh
15 hours ago
Great support in great timing...
We need urgent assistance on changes in a primary domain on our client's Cpanel accounts and reached...
Riyaju Deen
21 hours ago
Best Website Hosting platform ...
I was new on MilesWeb. And needed help on multiple areas from setting up to getting started with cre...
Harshada
1 days ago
Very quick and helpful assista...
Very quick and helpful assistance. Support person listened properly and provided a nice solution....
Narendra
1 days ago
the team is very supportive th...
the team is very supportive though at times effort needs to be made to make understand the problem s...
Suree Sharma
1 days ago
I am using miles web for 3plus...
I am using miles web for 3plus years, very quick and perfect support by the team, they helped me man...
Sri Raghav
2 days ago
The service is good...
The service is good. They are answering with patience and doing the needful as soon as possible....
MR
2 days ago
Perfect and Valuable Server + ...
I am using MilesWeb Servers, The main thing which I getting are continuous support over everything w...
Gunjan Makwana
3 days ago
Very quick and helpful assista...
Very quick and helpful assistance. Support person listened properly and provided a nice solution....
Narendra
4 days ago
positively helped me with find...
positively helped me with finding insecure content on my website causing SSL to not work properly on...
Thaviraj Junglee
4 days ago
Exceptional support, Truly Pra...
I had opted for the basic wordpress hosting plan as I intended to experiment with various plug-ins. ...
Aseem Chandna