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?


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's include() function.

Hope this helps :)

|improve this answer|||||

The get_footer() template tag is a custom wrapper for the locate_template() function, used to include a template-part file within a template file. The get_footer() template tag is part of the WordPress template system, and is used primarily by the Theme itself, to specify the footer.php or footer-{slug}.php file to include in the current template.

The wp_footer() template tag is a custom wrapper for the wp_footer action hook, which is invoked via do_action( 'wp_footer' ). The wp_footer() template tag is part of the WordPress Hooks API, and is used primarily by Plugins, to inject scripts in the site HTML footer.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.