Skip to content

_get_template_part

github-actions[bot] edited this page Jun 3, 2026 · 4 revisions

Allow template choices to be filtered.

The resulting array should be in the order of most specific first, to least specific last. e.g. 0 => recipe-instructions.php, 1 => recipe.php

Auto-generated Example

add_filter(
   '_get_template_part',
    function(
        array $templates,
        string $slug,
        string $name
    ) {
        // Your code here.
        return $templates;
    },
    10,
    3
);

Parameters

  • array $templates Names of template files that should be looked for, for given slug and name.
  • string $slug Template slug.
  • string $name Template variation name.

Files

apply_filters( $this->filter_prefix . '_get_template_part', $templates, $slug, $name )

← All Hooks

Clone this wiki locally