WP_Theme_JSON::get_template_parts(): array

In this article

Returns the template part data of active theme.

Return

array

Source

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

Changelog

VersionDescription
5.9.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.