get_template_part_<slug>
Fires before the specified template part file is loaded.
Description
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.
- // run the action
- do_action( 'get_template_part_{$slug}', $slug, $name );
- The following example is for adding a hook callback.
- // define the get_template_part_<slug> callback
- function action_get_template_part_slug( $slug, $name ) {
- // make action magic happen here...
- };
- // add the action
- add_action( "get_template_part_{$slug}", 'action_get_template_part_slug', 10, 2 );
- To remove a hook callback, use the example below.
- // remove the action
- 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
- do_action( "get_template_part_{$slug}", $slug, $name );