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.

Here is .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.

Go to Theme Editor Screen

2. On this screen, right side you will see theme files. Here all theme files are listed.

Theme files - WordPress Shortcode

3. Find out Theme Footer (footer.php) or Theme Header (header.php) file. Click on it.

Find header and footer files

4. Now you add the following .php code.

<?php
    echo do_shortcode('');
?>

5. Add a shortcode between the single quotes.

Add shortcode to Header/Footer in WordPress Website

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.

If you like our article, please consider buying a coffee for us.
Thanks for your support!

Support us on Buy me a coffee! Buy me a coffee!



2 Responses Leave a Comment

  1. It is working to my website thanks for the share

  2. thanks this informative information

Join the Discussion.