Summery Summery
Loads a template part into a template.
Syntax Syntax
Description Description
Provides a simple mechanism for child themes to overload reusable sections of code in the theme.
Includes the named template part for a theme or if a name is specified then a specialised part will be included. If the theme contains no {slug}.php file then no template will be included.
The template is included using require, not require_once, so you may include the same template part multiple times.
For the $name parameter, if the file is called "{slug}-special.php" then specify "special".
Parameters Parameters
- $slug
-
(Required) The slug name for the generic template.
- $name
-
(Optional) The name of the specialised template.
Default value: null
Source Source
File: wp-includes/general-template.php
if ( ! locate_template( $templates, true, true, $args ) ) { return false; } } /** * Loads a template part into a template. * * Provides a simple mechanism for child themes to overload reusable sections of code * in the theme. * * Includes the named template part for a theme or if a name is specified then a * specialised part will be included. If the theme contains no {slug}.php file * then no template will be included. * * The template is included using require, not require_once, so you may include the * same template part multiple times. * * For the $name parameter, if the file is called "{slug}-special.php" then specify * "special". * * @since 3.0.0 * @since 5.5.0 A return value was added. * @since 5.5.0 The `$args` parameter was added. * * @param string $slug The slug name for the generic template. * @param string $name The name of the specialised template. * @param array $args Optional. Additional arguments passed to the template. * Default empty array. * @return void|false Void on success, false if the template does not exist. */ function get_template_part( $slug, $name = null, $args = array() ) { /** * Fires before the specified template part file is loaded.
Advertisement
Changelog Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |