
Definition
In WordPress, get_footer() loads the theme footer file. By default it loads footer.php.
If you pass a name, such as get_footer( 'shop' ), WordPress looks for footer-shop.php first. If that file does not exist, it falls back to footer.php.
Syntax
Call it at the bottom of a template file.
<?php
get_footer();
// or a named footer:
get_footer( 'shop' );
| Call | What it does |
|---|
get_footer() | Loads footer.php. |
get_footer( 'shop' ) | Loads footer-shop.php, then footer.php if it is missing. |
get_footer( null, $args ) | Loads footer.php and passes data to it. |
Remember to call wp_footer() inside footer.php.
Full declaration
get_footer( string|null $name = null, array $args = [] ): void|false
Parameters
| Parameter | Description |
|---|
$name | string|null. The name of a special footer. Default is null. |
$args | array. Extra data for the footer file. It is available as $args inside it. Default is an empty array. |
Return Value
| Return Value | Description |
|---|
| void|false | The footer is loaded. It returns false if no footer file was found. |
WordPress Examples
Three short theme examples. Each one shows the code and what it prints.
Example 1 — Load the default footer
End a template with the footer.
<?php get_header(); ?>
<main>Page content</main>
<?php get_footer(); ?>
(header.php output)
<main>Page content</main>
(footer.php output)
How It Works
get_header() loads the top of the page.- Your content goes in the middle.
get_footer() loads footer.php.
Example 2 — A footer for the shop
Use a special footer on shop pages.
<?php get_footer( 'shop' ); ?>
Loads footer-shop.php
If footer-shop.php does not exist:
loads footer.php
How It Works
- The name is joined to
footer- and .php. - WordPress looks for
footer-shop.php first. - It falls back to
footer.php if needed.
Example 3 — Pass data to the footer
Tell the footer to hide the widgets.
<?php get_footer( null, array( 'show_widgets' => false ) ); ?>
<!-- in footer.php -->
<?php if ( ! isset( $args['show_widgets'] ) || $args['show_widgets'] ) : ?>
<?php dynamic_sidebar( 'footer-1' ); ?>
<?php endif; ?>
The footer widgets are not printed
because $args['show_widgets'] is false.
How It Works
- The second argument is an array of values.
- Inside
footer.php, the array is called $args. - The footer can now change what it prints.
Frequently Asked Questions
It loads footer.php from your theme, or a named footer file if you pass a name.
WordPress looks for footer-shop.php. If it is missing, it loads footer.php.
Your footer.php probably does not call wp_footer() before the closing body tag.
Yes. Pass an array as the second argument. It is available as $args in the footer file (WordPress 5.5 and later).
About the author
Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
7 people found this page helpful