get_custom_templates example


function _add_block_template_info( $template_item ) {
    if ( ! wp_theme_has_theme_json() ) {
        return $template_item;
    }

    $theme_data = WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_custom_templates();
    if ( isset( $theme_data[ $template_item['slug'] ] ) ) {
        $template_item['title']     = $theme_data[ $template_item['slug'] ]['title'];
        $template_item['postTypes'] = $theme_data[ $template_item['slug'] ]['postTypes'];
    }

    return $template_item;
}

/** * Attempts to add the template part's area information to the input template. * * @since 5.9.0 * @access private * * @param array $template_info Template to add information to (requires 'type' and 'slug' fields). * @return array Template info. */
Home | Imprint | This part of the site doesn't use cookies.