Title: theme_page_templates
Published: April 25, 2014
Last modified: August 16, 2016

---

# apply_filters( ‘theme_page_templates’, array $page_templates, WP_Theme $this, WP_Post|null $post )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/theme_page_templates/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/theme_page_templates/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/hooks/theme_page_templates/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/theme_page_templates/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/hooks/theme_page_templates/?output_format=md#wp--skip-link--target)

Filters list of page templates for a theme.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/theme_page_templates/?output_format=md#parameters)󠁿

 `$page_templates`array

Array of page templates. Keys are filenames, values are translated names.

`$this`[WP_Theme](https://developer.wordpress.org/reference/classes/wp_theme/)

The theme object.

`$post`[WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)|null

The post being edited, provided for context, or null.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/theme_page_templates/?output_format=md#source)󠁿

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-theme.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-theme.php#L1057)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-theme.php#L1057-L1057)

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/theme_page_templates/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.4.0](https://developer.wordpress.org/reference/since/4.4.0/) | Converted to allow complete control over the `$page_templates` array. | 
| [3.9.0](https://developer.wordpress.org/reference/since/3.9.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/theme_page_templates/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 4 content](https://developer.wordpress.org/reference/hooks/theme_page_templates/?output_format=md#comment-content-3575)
 2.    [Julie Kuehl](https://profiles.wordpress.org/juliekuehl/)  [  6 years ago  ](https://developer.wordpress.org/reference/hooks/theme_page_templates/#comment-3575)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Ftheme_page_templates%2F%23comment-3575)
     Vote results for this note: 2[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Ftheme_page_templates%2F%23comment-3575)
 4.  If you want to remove templates from both Pages and Posts, you will need to also
     use the `theme_post_templates` in addition to the `theme_page_templates` filter.
 5.      ```php
         /* Remove parent theme page templates */
     
         function child_remove_page_templates( $page_templates ) {
           unset( $page_templates['template-cover.php'] );
           unset( $page_templates['template-full-width-cover.php'] );
           unset( $page_templates['template-full-width-only-content.php'] );
           unset( $page_templates['template-full-width.php'] );
           unset( $page_templates['template-only-content.php'] );
     
           return $page_templates;
         }
         add_filter( 'theme_page_templates', 'child_remove_page_templates' );
         add_filter( 'theme_post_templates', 'child_remove_page_templates' );
         ```
     
 6.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Ftheme_page_templates%2F%3Freplytocom%3D3575%23feedback-editor-3575)
 7.   [Skip to note 5 content](https://developer.wordpress.org/reference/hooks/theme_page_templates/?output_format=md#comment-content-285)
 8.    [SpartakusMd](https://profiles.wordpress.org/spartakusmd/)  [  11 years ago  ](https://developer.wordpress.org/reference/hooks/theme_page_templates/#comment-285)
 9.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Ftheme_page_templates%2F%23comment-285)
     Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Ftheme_page_templates%2F%23comment-285)
 10. **Filter page templates by blog id**
 11. Suppose you have the blog `Food` with the id 2 and the template `page-food.php`
     which should only be used for this blog. The example below removes the page template
     from dropdowns of other blogs:
 12.     ```php
         /**
          * Filter the theme page templates.
          *
          * @param array    $page_templates Page templates.
          * @param WP_Theme $this           WP_Theme instance.
          * @param WP_Post  $post           The post being edited, provided for context, or null.
          * @return array (Maybe) modified page templates array.
          */
         function wpdocs_filter_theme_page_templates( $page_templates, $this, $post ) {
         	$current_blog_id = get_current_blog_id();
         	$food_blog_id    = 2;
     
         	if ( $current_blog_id != $food_blog_id ) {
         		if ( isset( $page_templates['page-food.php'] ) ) {
         			unset( $page_templates['page-food.php'] );
         		}
         	}
         	return $page_templates;
         }
         add_filter( 'theme_page_templates', 'wpdocs_filter_theme_page_templates', 20, 3 );
         ```
     
 13.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Ftheme_page_templates%2F%3Freplytocom%3D285%23feedback-editor-285)
 14.  [Skip to note 6 content](https://developer.wordpress.org/reference/hooks/theme_page_templates/?output_format=md#comment-content-4634)
 15.   [mrwweb](https://profiles.wordpress.org/mrwweb/)  [  5 years ago  ](https://developer.wordpress.org/reference/hooks/theme_page_templates/#comment-4634)
 16. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Ftheme_page_templates%2F%23comment-4634)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Ftheme_page_templates%2F%23comment-4634)
 17. To filter the “Default template” option in the list of Page Templates, see [`default_page_template_title`](https://developer.wordpress.org/reference/hooks/default_page_template_title/).
 18.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Ftheme_page_templates%2F%3Freplytocom%3D4634%23feedback-editor-4634)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Ftheme_page_templates%2F)
before being able to contribute a note or feedback.