Summery Summery

Filters list of page templates for a theme.

Syntax Syntax

apply_filters( "theme_{$post_type}_templates", string[] $post_templates, WP_Theme $this, WP_Post|null $post, string $post_type )

Description Description

The dynamic portion of the hook name, $post_type, refers to the post type.

Parameters Parameters


(string[]) Array of template header names keyed by the template file name.


(WP_Theme) The theme object.


(WP_Post|null) The post being edited, provided for context, or null.


(string) Post type to get the templates for.

Source Source

File: wp-includes/class-wp-theme.php


Changelog Changelog

Version Description
4.7.0 Added the $post_type parameter.
4.4.0 Converted to allow complete control over the $page_templates array.
3.9.0 Introduced.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.