WP_Theme_JSON::get_template_parts()publicWP 5.9.0

Returns the template part data of active theme.

{} It's a method of the class: WP_Theme_JSON{}

No Hooks.

Return

Array.

Usage

$WP_Theme_JSON = new WP_Theme_JSON();
$WP_Theme_JSON->get_template_parts();

Changelog

Since 5.9.0 Introduced.

Code of WP_Theme_JSON::get_template_parts() WP 6.0

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;
}