WP_Theme_JSON::get_custom_templates() – Returns the page templates of the current theme.

You appear to be a bot. Output may be restricted

Description

Returns the page templates of the active theme.

Usage

$array = WP_Theme_JSON::get_custom_templates();

Parameters

Returns

array

Source

File name: wordpress/wp-includes/class-wp-theme-json.php
Lines:

1 to 16 of 16
  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 on GitHub View on Trac