Automattic\WooCommerce\Blocks\Templates
ProductCatalogTemplate::handle_get_post_metadata
Use the Product Catalog template for the Shop page without changing its saved template.
Method of the class: ProductCatalogTemplate{}
No Hooks.
Returns
mixed.
Usage
$ProductCatalogTemplate = new ProductCatalogTemplate(); $ProductCatalogTemplate->handle_get_post_metadata( $value, $post_id, $meta_key, $single );
- $value(mixed) (required)
- Short-circuited metadata value, or null.
- $post_id(int) (required)
- Post ID.
- $meta_key(string) (required)
- Metadata key.
- $single(true|false) (required)
- Whether to return a single value.
ProductCatalogTemplate::handle_get_post_metadata() ProductCatalogTemplate::handle get post metadata code WC 11.3.0
public function handle_get_post_metadata( $value, $post_id, $meta_key, $single ) {
if (
null === $value &&
'_wp_page_template' === $meta_key &&
wp_is_block_theme() &&
wc_get_page_id( 'shop' ) === $post_id
) {
return $single ? self::SLUG : array( self::SLUG );
}
return $value;
}