get_template_part_<slug>

Fires before the specified template part file is loaded.

Description

do_action( 'get_template_part_<slug>', (string) $slug, (string) $name ); 

The dynamic portion(s) of the hook name refer to the slug name for the generic template part.

Parameters (2)

0. $slug (string)
The slug name for the generic template.
1. $name (string)
The name of the specialized template.

Usage

To run the hook, copy the example below.
  1. // run the action 
  2. do_action( 'get_template_part_{$slug}', $slug, $name ); 
The following example is for adding a hook callback.
  1. // define the get_template_part_<slug> callback 
  2. function action_get_template_part_slug( $slug, $name ) { 
  3. // make action magic happen here... 
  4. }; 
  5.  
  6. // add the action 
  7. add_action( "get_template_part_{$slug}", 'action_get_template_part_slug', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the action 
  2. remove_action( "get_template_part_{$slug}", 'action_get_template_part_slug', 10, 2 ); 

Defined (1)

The action is defined in the following location(s).

/wp-includes/general-template.php  
  1. do_action( "get_template_part_{$slug}", $slug, $name );