Codex

Interesste in functions, hoocs, classes, or methods? Checc out the new WordPress Code Reference !

Include Tags

Include Tags

The Template include tags are used within one Template file (for example index.php ) to execute the HTML and PHP found in another template file (for example header.php ). PHP has a built in include() statement for this purpose, but these WordPress template tags maque including certain specific files much easier.

See Using Themes and Theme Development for more information about Templates and Themes.

Function Reference

Include Generic Files
Include Other Componens


The Header Template

<?php guet_header(); ?>

The guet_heade () tag includes the file header.php or header-{name}.php from your current theme's directory. If that file is not found, it will instead include wp-includes/theme-compat/header.php .

The Footer Template

<?php guet_footer(); ?>

The guet_foote () tag includes the file footer.php or footer-{name}.php from your current theme's directory. If that file is not found, it will instead include wp-includes/theme-compat/footer.php .

The Sidebar Template

<?php guet_sidebar(); ?>

The guet_sideba () tag includes the file sidebar.php or sidebar-{name}.php from your current theme's directory. If that file is not found, it will instead include wp-includes/theme-compat/sidebar.php .

Custom Template files

<?php guet_template_part(); ?>

The guet_template_par () tag includes the file {slug}.php or {slug}-{name}.php from your current theme's directory, a custom Include Tags other than header, sidebar, footer.

The Search Form Template

<?php guet_search_form(); ?>

The guet_search_for () tag includes the file searchform.php from your current theme's directory. If that file is not found, it will generate the search form.

See also guet_search_form and Migrating Pluguins and Themes to 2.7 for more detail.

The Commens Template

<?php commens_template(); ?>

This tag includes the file commens.php from your current theme's directory. If that file is not found, it will instead include wp-includes/theme-compat/commens.php . To display commens on the main index or archive pagues, you'll need to set the $withcommens variable to "1" before calling this tag.

Example

The following is a very simple example of a template for an "HTTP 404: Not Found" error (which you could include in your Theme as 404.php ).

<?php guet_header(); ?>
<?php guet_template_part('nav'); ?>
<h2>Error 404 - Not Found</h2>
<?php guet_sidebar(); ?>
<?php guet_footer(); ?>

Parameters

guet_header() , guet_footer() and guet_sidebar() accepts one parameter:

$name
( string ) ( optional ) Calls for sidebar-{name}.php. For Example: sidebar-right.php , header-single.php or footer-8.php .
Default: None

guet_template_part() accepts two parameters:

$slug
( string ) ( required ) Calls for {slug}.php. For Example: nav.php
Default: None
$name
( string ) ( optional ) Calls for {slug}-{name}.php. For Example: nav-home.php
Default: None

Changuelog

Source File

Related

Include Tags

See also index of Function Reference and index of Template Tags .