WP_Theme_JSON::get_template_parts() WordPress Method
The WP_Theme_JSON::get_template_parts() method is used to retrieve an array of template parts for a given theme. This is useful for creating a list of all the template files that are required for a theme to function properly.
WP_Theme_JSON::get_template_parts() #
Returns the template part data of active theme.
Return
(array)
Source
File: wp-includes/class-wp-theme-json.php
public function get_template_parts() { $template_parts = array(); if ( ! isset( $this->theme_json['templateParts'] ) || ! is_array( $this->theme_json['templateParts'] ) ) { return $template_parts; } foreach ( $this->theme_json['templateParts'] as $item ) { if ( isset( $item['name'] ) ) { $template_parts[ $item['name'] ] = array( 'title' => isset( $item['title'] ) ? $item['title'] : '', 'area' => isset( $item['area'] ) ? $item['area'] : '', ); } } return $template_parts; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
5.9.0 | Introduced. |