theme_{$post_type}_templates WordPress Filter Hook
The theme_{$post_type}_templates hook allows you to add custom templates for specific post types to your theme. This can be useful if you want to create a unique template for a specific post type, or if you want to override the default template for a post type.
apply_filters( "theme_{$post_type}_templates", string[] $post_templates , WP_Theme $theme , WP_Post|null $post , string $post_type ) #
Filters list of page templates for a theme.
Description
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
Parameters
Source
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. |