WP_Block_Template WordPress Class

The WP_Block_Template class is a class used to create custom templates for specific WordPress blocks. This class can be used to create custom templates for any block, and is especially useful for creating custom templates for blocks that are not available in the WordPress default template hierarchy.

WP_Block_Template #

Class representing a block template.


Source

File: wp-includes/class-wp-block-template.php

class WP_Block_Template {

	/**
	 * Type: wp_template.
	 *
	 * @since 5.8.0
	 * @var string
	 */
	public $type;

	/**
	 * Theme.
	 *
	 * @since 5.8.0
	 * @var string
	 */
	public $theme;

	/**
	 * Template slug.
	 *
	 * @since 5.8.0
	 * @var string
	 */
	public $slug;

	/**
	 * ID.
	 *
	 * @since 5.8.0
	 * @var string
	 */
	public $id;

	/**
	 * Title.
	 *
	 * @since 5.8.0
	 * @var string
	 */
	public $title = '';

	/**
	 * Content.
	 *
	 * @since 5.8.0
	 * @var string
	 */
	public $content = '';

	/**
	 * Description.
	 *
	 * @since 5.8.0
	 * @var string
	 */
	public $description = '';

	/**
	 * Source of the content. `theme` and `custom` is used for now.
	 *
	 * @since 5.8.0
	 * @var string
	 */
	public $source = 'theme';

	/**
	 * Origin of the content when the content has been customized.
	 * When customized, origin takes on the value of source and source becomes
	 * 'custom'.
	 *
	 * @since 5.9.0
	 * @var string
	 */
	public $origin;

	/**
	 * Post ID.
	 *
	 * @since 5.8.0
	 * @var int|null
	 */
	public $wp_id;

	/**
	 * Template Status.
	 *
	 * @since 5.8.0
	 * @var string
	 */
	public $status;

	/**
	 * Whether a template is, or is based upon, an existing template file.
	 *
	 * @since 5.8.0
	 * @var bool
	 */
	public $has_theme_file;

	/**
	 * Whether a template is a custom template.
	 *
	 * @since 5.9.0
	 *
	 * @var bool
	 */
	public $is_custom = true;

	/**
	 * Author.
	 *
	 * A value of 0 means no author.
	 *
	 * @since 5.9.0
	 * @var int
	 */
	public $author;

	/**
	 * Post types.
	 *
	 * @since 5.9.0
	 * @var array
	 */
	public $post_types;

	/**
	 * Area.
	 *
	 * @since 5.9.0
	 * @var string
	 */
	public $area;
}

Top ↑

Changelog

Changelog
VersionDescription
5.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.