# get_template_part()

URL: https://chugunov.pro/api-wordpress/functions/get_template_part/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 3.0.0.

## Сигнатура

```php
get_template_part( string $slug, string|null $name = null, array $args = array() ): void|false
```

## Описание

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 specialized 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”.

## Параметры

- `$slug` `string` — обязательный. Слаг-имя для универсального шаблона.
- `$name` `string|null` — необязательный, по умолчанию `null`. Имя специализированного шаблона.
- `$args` `array` — необязательный, по умолчанию `array()`. Дополнительные аргументы, передаваемые в шаблон.

## Возвращаемое значение

`void|false`

## Исходный код

Файл: `wp-includes/general-template.php:167`

```php
function get_template_part( $slug, $name = null, $args = array() ) {
	/**
	 * Fires before the specified template part file is loaded.
	 *
	 * The dynamic portion of the hook name, `$slug`, refers to the slug name
	 * for the generic template part.
	 *
	 * @since 3.0.0
	 * @since 5.5.0 The `$args` parameter was added.
	 *
	 * @param string      $slug The slug name for the generic template.
	 * @param string|null $name The name of the specialized template
	 *                          or null if there is none.
	 * @param array       $args Additional arguments passed to the template.
	 */
	do_action( "get_template_part_{$slug}", $slug, $name, $args );

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

	$templates[] = "{$slug}.php";

	/**
	 * Fires before an attempt is made to locate and load a template part.
	 *
	 * @since 5.2.0
	 * @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 specialized template
	 *                            or an empty string if there is none.
	 * @param string[] $templates Array of template files to search for, in order.
	 * @param array    $args      Additional arguments passed to the template.
	 */
	do_action( 'get_template_part', $slug, $name, $templates, $args );

	if ( ! locate_template( $templates, true, false, $args ) ) {
		return false;
	}
}
```

## История изменений

- 5.5.0 — The $args parameter was added.
- 3.0.0 — Introduced.

## Связанные

Использует: [`locate_template`](https://chugunov.pro/api-wordpress/functions/locate_template/), [`do_action`](https://chugunov.pro/api-wordpress/functions/do_action/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/get_template_part/
