wppaste
WordPress

do_action( "get_template_part_{$slug}", string $slug, string|null $name, array $args )

Since
3.0.0, 5.5.0
Fires before the specified template part file is loaded.

Description

The dynamic portion of the hook name, $slug, refers to the slug name for the generic template part.

Compatibility

WordPress
since 5.5.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Parameters

$slugstring
The slug name for the generic template.
$namestring|null
The name of the specialized template or null if there is none.
$argsarray
Additional arguments passed to the template.

Where this hook fires · 1

  • wp-includes/general-template.php:182get_template_part()

Source code

	 *	 * @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";	}

Changelog

Introduced in 3.0.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

5.5.0
The $args parameter was added.from the docblock
3.0.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.