The wp_footer
and wp_head
functions, also known as “action hooks”, are essential for most plugins, otherwise, they won’t work properly or at all.
Plugins need these hooks in order to add proper code in your theme’s </head>
or </footer>
area.
Every well-developed theme should have those functions added, but, unfortunately, not all themes are well-developed.
Some plugins will let you know if they require either the wp_footer
or wp_head
hook in order to work, but some won’t, mostly because they expect a theme to already have these functions added.
Let’s take, for example, our “Lazy Load for Videos” plugin, which let us know that starting with the 2.2.0.4 version, the wp_footer
function is required.
When you see something like that, you’ll probably want to check if your theme has such function, so let’s see how you can do that.
How to check if a WordPress theme has the wp_footer function
1. Check with your WordPress theme “Editor”
If you don’t have any WordPress security measures that prevents this, you need to:
- Go to Appearance -> Editor.
- Search for Footer (footer.php) on the right side, then click on it.
- Now scroll down and see if you have this code
<?php wp_footer(); ?>
right before the</body>
tag, where it should normally be added. If it isn’t there, it means your theme doesn’t have it, but I’ll tell you below how to add it.
Note that the code can also look something like this:
<?php
wp_footer();
?>
In order to check quicker, just press Ctrl-F (Command-F for Mac) on your keyboard and add </body>
or wp-footer
, then press “Enter”.
2. Check with cPanel’s File Manager
All you need to do is to:
- Log in to cPanel and find File Manager, then click on it.
- Go to public_html -> wp-content -> themes -> select the theme you are using.
- Then search for footer.php, right-click on it and click “View”.
- Now check if you have this code
<?php wp_footer(); ?>
right before the</body>
tag.
How to add wp_footer to a theme
In case you don’t have that function, you could add it yourself!
You just need to edit the file through your theme Editor (see point 1), cPanel’s File Manager (see point 2, but click “Edit” instead of “View”) or a 3rd party software (e.g. FileZilla or SmartFTP), by adding this <?php wp_footer(); ?>
above the </body>
tag.
How to check if a WordPress theme has the wp_head function
1. Check with your WordPress theme “Editor”
The process is like the one shown for wp_footer
, except that:
- You have to click on the Header (header.php).
- Now check if you have this code
<?php wp_head(); ?>
right before the</head>
tag, where it should normally be. If it’s not there, you’ll need to add it yourself, as you’ll see below.
Note that the code can also look something like this:
<?php
wp_head();
?>
In order to check quicker, just press Ctrl-F (Command-F for Mac) on your keyboard, and add </head>
or wp_head
, then press “Enter”.
2. Check with cPanel’s File Manager
Follow the wp_footer
example, but check the header.php file to see if it has the code before the </head>
tag.
How to add wp_head to a theme
The process is similar to wp_footer
, except you need to edit the header.php, and add this code <?php wp_head(); ?>
right before the </head>
tag.
Of course, don’t forget to press “Save”, “Save changes”, “Update file”, etc., after you made the changes!
That’s a wrap
Hope our guide was comprehensive enough in order for you to detect or add those essential WordPress action hooks!
If you have any questions or thoughts, please drop a comment or contact us! And don’t forget to share if you enjoyed the article!
Leave A Comment