theme_{$post_type}_templates

FILTER wp-includes\class-wp-theme.php (ligne 1434) github
Filters list of page templates for a theme. The dynamic portion of the hook name, `$post_type`, refers to the post type. Possible hook names include:  - `theme_post_templates`  - `theme_page_templates`  - `theme_attachment_templates`

Paramètres

Entrée :
$post_templates, $this, $post, $post_type
Sortie :
@param string[]     $post_templates Array of template header names keyed by the template file name.
@param WP_Theme     $theme          The theme object.
@param WP_Post|null $post           The post being edited, provided for context, or null.
@param string       $post_type      Post type to get the templates for.

Utilisation

// Modifier la valeur avec le filtre 'theme_{$post_type}_templates'
add_filter('theme_{$post_type}_templates', 'ma_fonction_filtre', 10, 1);

function ma_fonction_filtre($post_templates) {
    // Modifier la valeur
    return $post_templates;
}

Actualités

Chargement des actualités...