Title: WP_Theme_JSON::get_custom_templates
Published: February 3, 2022
Last modified: February 24, 2026

---

# WP_Theme_JSON::get_custom_templates(): array

## In this article

 * [Return](https://developer.wordpress.org/reference/classes/wp_theme_json/get_custom_templates/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_theme_json/get_custom_templates/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_theme_json/get_custom_templates/?output_format=md#changelog)

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

Returns the page templates of the active theme.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_theme_json/get_custom_templates/?output_format=md#return)󠁿

 array

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

    ```php
    public function get_custom_templates() {
    	$custom_templates = array();
    	if ( ! isset( $this->theme_json['customTemplates'] ) || ! is_array( $this->theme_json['customTemplates'] ) ) {
    		return $custom_templates;
    	}

    	foreach ( $this->theme_json['customTemplates'] as $item ) {
    		if ( isset( $item['name'] ) ) {
    			$custom_templates[ $item['name'] ] = array(
    				'title'     => isset( $item['title'] ) ? $item['title'] : '',
    				'postTypes' => isset( $item['postTypes'] ) ? $item['postTypes'] : array( 'page' ),
    			);
    		}
    	}
    	return $custom_templates;
    }
    ```

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

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

| Version | Description | 
| [5.9.0](https://developer.wordpress.org/reference/since/5.9.0/) | Introduced. |

## User Contributed Notes

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