softmaji-header-wbg-min
softmaji-header-wbg-min
softmaji-blue-header-min
softmaji-blue-header-min
  • Home
  • Services
    • Website Designing
      • Responsive Website Design
      • Static Website Design
      • Website Redesign
      • Landing Page Design
    • Website Development
      • PHP Website Development
      • WordPress Website Development
      • Ecommerce Website Development
      • Custom Website Development
    • Digital Marketing
      • Google Adwords/PPC
      • Facebook Promotion
    • SEO Service
  • Trainings
    • Learn Web Development
    • Learn Graphics Design
    • Learn Business Communication Skills
  • Pricing
  • Portfolio
  • Events
  • Offers
  • Contact Us

Discover the Steps To Use WordPress do_shortcode

HomeDiscover the Steps To Use WordPress do_shortcode

Offer Expire Soon..


Only New User..


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!

Table of Contents

Toggle
  • What Exactly is Shortcode?
  • Steps to Use WordPress do_shortcode
  • Conclusion

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:

<?php echo do_shortcode( '[your shortcode goes here]' ); ?>

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!

Faizan Khan
15
Latest News
Prev PostSteps to Create a Custom WordPress 404 Error PageMay 14, 2024
Next PostLearn to Fix the ‘No update required’ Message in WordPressMay 14, 2024

Related items

Latest News

How To Install WordPress Blog?

Let’s see how to install WordPress blog on your WordPress hosting account. Let’s

Faizan Khan
14/05/2024
145
Latest News

How to Install a Theme in WordPress?

Steps to install a theme in WordPress: Log in to WordPress. Navigate to Appearance and cli

Faizan Khan
14/05/2024
128
Latest News

Fatal error: Allowed memory size of xxxx bytes exhausted (tried to allocate xx bytes)

WordPress is a free open source blogging tool. When posting a article OR uploading a image

Faizan Khan
14/05/2024
140
softmaji-header-wbg-min
SoftMaji is one of the affordable web development company in the web development industry. You don’t have to go searching anywhere for finding a reliable web development partner because we have crafted web development solutions that can fill the void left by others in the market.
Services
  • News Portal Development
  • Custom Website Development
  • PHP Website Development
  • Ecommerce Website Development
  • WordPress Website Development
Shortlinks
  • Blog
  • Offers
  • Events
  • Pricing
  • Reviews
  • Portfolio
  • Our Team
  • Payment Options
  • Explore Packages
Company
  • FAQ
  • Careers
  • Sitemap
  • Feedback
  • About Us
  • Contact Us
  • Privacy Policy
  • Terms & Conditions
  • Refund And Cancellation
Contact Us
4/40 Vipul Khand , Gomti Nagar Lucknow
Uttar Pradesh 226010
Landline - +915223162418
Email - hello@softmaji.in
Office Time Mon - Sat
(10:00AM - 5:00PM)
Sunday Close
+91 9795405324
Lucknow , Uttar Pradesh
Copyright © 2022. All Rights Reserved.