WordPress at a glance

get_footer() WP 1.5.0

Includes the footer.php template file from your current theme's directory. If a $name is specified then footer-{name}.php file will be included.

If the theme contains no footer.php file then the footer from the default theme wp-includes/theme-compat/footer.php will be included.

Works based on: locate_template()
Hooks from the function
Return

Null. Nothing.

Usage

get_footer( $name );
$name(string)
The name of the specialised footer.
Default: null

Examples

#1 Simple 404 page

<?php get_header(); ?>
<h2>Error 404 - Not Found</h2>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

#2 Multiple Footers

<?php
if ( is_home() ) :
  get_footer('home');
elseif ( is_404() ) :
  get_footer('404');
else :
  get_footer();
endif;
?>

The file names for the home and 404 footers should be footer-home.php and footer-404.php respectively.

Changelog

Since 1.5.0 Introduced.

Code of get footer: wp-includes/general-template.php WP 5.2.2

<?php
function get_footer( $name = null ) {
	/**
	 * Fires before the footer template file is loaded.
	 *
	 * @since 2.1.0
	 * @since 2.8.0 $name parameter added.
	 *
	 * @param string|null $name Name of the specific footer file to use. null for the default footer.
	 */
	do_action( 'get_footer', $name );

	$templates = array();
	$name      = (string) $name;
	if ( '' !== $name ) {
		$templates[] = "footer-{$name}.php";
	}

	$templates[] = 'footer.php';

	locate_template( $templates, true );
}

Related Functions

From category: Theme files connection

More from Template Tags: Main Functions

vladlu 100vlad.lu
Editors: kama 100
No comments
    Hello, !     Log In . Register