Build a unified template object based a post Object.
Parameters
$post
WP_Postrequired- Template post.
Source
if ( ! defined( 'WP_TEMPLATE_PART_AREA_UNCATEGORIZED' ) ) {
define( 'WP_TEMPLATE_PART_AREA_UNCATEGORIZED', 'uncategorized' );
}
/**
* For backward compatibility reasons,
* block themes might be using block-templates or block-template-parts,
* this function ensures we fallback to these folders properly.
*
* @since 5.9.0
*
* @param string $theme_stylesheet The stylesheet. Default is to leverage the main theme root.
*
* @return string[] {
* Folder names used by block themes.
*
* @type string $wp_template Theme-relative directory name for block templates.
* @type string $wp_template_part Theme-relative directory name for block template parts.
* }
*/
function get_block_theme_folders( $theme_stylesheet = null ) {
$theme = wp_get_theme( (string) $theme_stylesheet );
if ( ! $theme->exists() ) {
// Return the default folders if the theme doesn't exist.
return array(
'wp_template' => 'templates',
'wp_template_part' => 'parts',
);
Changelog
Version | Description |
---|---|
5.8.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.