I am designing my 404 error page, for which I created a separate header and of course I need a separate footer. As for the latter, instead of creating a new one, would be enough for me to ensure thewp_footer(); to be just before the closing body?

Or is there something in the get_footer() function that makes it necessary?


get_footer() will bring footer.php, so including wp_footer() before the </body> will be more than enough in this case.


You can create differents footers and headers files. For example, a default header.php and footer.php and specific templates like header-error.php and footer-error.php. In general, you will have this code to inclue header.php and footer.php:

//Your page tempalte

In 404.php template file you can include header-error.php and footer-error.php as follow:

//Your template

Or you can create a full 404.php template, including full header and full footer, without calling get_header and get_footer functions at all.

More info in get_header() and get_footer() documentation.

  • Thanks, but my question was slightly different. I was after to understand whether the get_footer includes something that makes it necessary. – Andrea Moro May 30 '14 at 7:19

Best practice is to keep wp_footer() in your footer.php. Although the codex says, and I quote

Put this template tag immediately before tag in a theme template (ex. footer.php, index.php).

it is best keeping wp_footer() in the footer. From the PluginAPI for the wp_footer action

When included, the default output for this function is the admin panel which will be shown in the top of the theme. It should be kept in the footer for every theme because most of the plugin bind their script files or functions to this hook.

To conclude, when creating a custom footer.php, include wp_footer() in this custom template as well.


Just to elaborate more on your question. The closing </body> tag is the 2nd last tag called for a page, and is situated in the footer.php. Also, most importantly, the closing </html> tag is the last tag in the footer.php. This wraps up your site.

Have a look at the footer for the bundled theme, twentyfourteen

 * The template for displaying the footer
 * Contains footer content and the closing of the #main and #page div elements.
 * @package WordPress
 * @subpackage Twenty_Fourteen
 * @since Twenty Fourteen 1.0

        </div><!-- #main -->

        <footer id="colophon" class="site-footer" role="contentinfo">

            <?php get_sidebar( 'footer' ); ?>

            <div class="site-info">
                <?php do_action( 'twentyfourteen_credits' ); ?>
                <a href="<?php echo esc_url( __( 'http://wordpress.org/', 'twentyfourteen' ) ); ?>"><?php printf( __( 'Proudly powered by %s', 'twentyfourteen' ), 'WordPress' ); ?></a>
            </div><!-- .site-info -->
        </footer><!-- #colophon -->
    </div><!-- #page -->

    <?php wp_footer(); ?>

The last three lines of code is the most important.So it is very important to have a footer for these reasons as well, otherwise you will break the <body> and <html> tags. Don't leave out the footer, rather copy your footer.php, rename it, customize it, and call it where needed, and remember, don't move wp_footer() out of the footer

  • Added a link to the pluginAPI – Pieter Goosen May 30 '14 at 7:25

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.