get_template_part WordPress Action Hook
The get_template_part hook is used to include a template file from a child or parent theme. This hook is typically used in the header or footer of a theme. The get_template_part hook takes two arguments: 1. The slug of the template file to include. 2. The name of the file to be included. For example, if the slug of the template file to be included is “header” and the name of the file is “header.php”, the following code would be used: This hook is useful for including a template file from a child or parent theme. It is also useful for including a template file from a plugin.
do_action( 'get_template_part', string $slug , string $name , string[] $templates , array $args ) #
Fires before an attempt is made to locate and load a template part.
Parameters
- $slug
(string)The slug name for the generic template.
- $name
(string)The name of the specialized template.
- $templates
(string[])Array of template files to search for, in order.
- $args
(array)Additional arguments passed to the template.
Source
Changelog
Version | Description |
---|---|
5.5.0 | The $args parameter was added. |
5.2.0 | Introduced. |