I am working on developing a plugin, and I am trying to add a line of text to the bottom of the page, I see there are two actions that seems reasonable, wp_footer()
and get_footer()
. wp_footer sounds like it may more suited towards code that needs to go at the very end of the page (like JavaScript files), but get_footer didn’t have any documentation on its wordpress codex page. Which should I use for something like this?
Leave a Reply
You must be logged in to post a comment.
These two functions accomplish two different things.
wp_footer()
is a hook used in your footer.php template file to ensure that the right code is inserted (from the core/plugins/etc) into the right place.get_footer()
is used in your other template files to call for the code in your footer.php template file.So in simpler words
wp_footer()
gets other code that you most likely don’t produce (but need), so it’s a little more abstract.get_footer()
grabs the exact code that you wrote into your footer.php file so it is the WordPress version of PHP’sinclude()
function.Hope this helps 🙂
The
get_footer()
template tag is a custom wrapper for thelocate_template()
function, used to include a template-part file within a template file. Theget_footer()
template tag is part of the WordPress template system, and is used primarily by the Theme itself, to specify thefooter.php
orfooter-{slug}.php
file to include in the current template.The
wp_footer()
template tag is a custom wrapper for thewp_footer
action hook, which is invoked viado_action( 'wp_footer' )
. Thewp_footer()
template tag is part of the WordPress Hooks API, and is used primarily by Plugins, to inject scripts in the site HTML footer.