How to add a shortcode to Header/Footer in WordPress Website
Sometimes you might need to add dynamic content to header/footer in your WordPress website. WordPress provides a shortcode that you can add to the header/footer of your WordPress site. In this entry, we’ll show you how to add a shortcode to the header/footer in your WordPress website.
WordPress shortcodes are a WordPress specific code that provides you extra functionality with very little effort. Thousands of plugins and themes are used shortcodes to make their website content more dynamic.
Shortcode is one of the most underestimated features of WordPress. Using shortcodes to make a more user-friendly WordPress website, unlike any other platform.
Add a Shortcode to Header or Footer in WordPress
The following tutorial will show you how to add a shortcode to header or footer parts in WordPress Website.
.php code that you need to add to the header/footer of your WordPress website.
<?php echo do_shortcode('[shortcode-here]'); ?>
Mostly, the header and footer parts are limited modifiable content areas. So you need to manually add above code into header and footer parts.
The following way you can add a shortcode into your header/footer parts.
1. Go to your WordPress dashboard and click on Appearance → Theme Editor.
2. On this screen, right side you will see theme files. Here all theme files are listed.
3. Find out Theme Footer (
footer.php) or Theme Header (
header.php) file. Click on it.
4. Now you add the following .php code.
<?php echo do_shortcode(''); ?>
5. Add a shortcode between the single quotes.
6. Once you added the shortcode, update the changes and go to the website to see the changes applied.
We hope you have found this article helpful. Let us know your questions or feedback if any through the comment section in below. You can subscribe our newsletter and get notified when we publish new WordPress articles for free. Moreover, you can explore here other WordPress related articles.