• Resolved agm285

    (@agm285)


    What does wp_footer() do? It exists in the footer.php file (I’m using a starter theme, _s) but does not appear to add anything to the page. I looked up the function, but the code is simply:

    function wp_footer() {
        /**
         * Print scripts or data before the closing body tag on the front end.
         *
         * @since 1.5.1
         */
        do_action( 'wp_footer' );
    }

    What “scripts or data” does the comment refer to?

Viewing 2 replies - 1 through 2 (of 2 total)
  • It doesn’t do anything on its own; theme and plugin authors write functions hooked to the wp_footer action to write to the footer of the site. It’s most commonly used to write JavaScript to the footer so it doesn’t block rendering (via wp_enqueue_script()), but IIRC the HTML for the admin bar is written to the footer as well.

    Thread Starter agm285

    (@agm285)

    Got it. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘footer.php vs wp_footer()’ is closed to new replies.