Filter
rpress_get_template_part
On this page
Filters the template file names searched for a template part.
Runs in rpress_get_template_part() after the candidate list is built. When a name is given the list starts with slug-name.php, followed by slug.php. The result is passed to rpress_locate_template(), which checks the theme directories first.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$templates | array | Candidate template file names, in order of preference. |
$slug | string | Template slug. |
$name | string|null | Template name, or null. |
Return value#
array. Candidate template file names.
Example#
function my_template_part_candidates( $templates, $slug, $name ) {
if ( 'list/fooditems' === $slug ) {
array_unshift( $templates, 'my-' . $slug . '.php' );
}
return $templates;
}
add_filter( 'rpress_get_template_part', 'my_template_part_candidates', 10, 3 );
Source#
Applied in:
includes/template-functions.php(line 621), inrpress_get_template_part()
See also#
Was this page helpful?
