Automattic\WooCommerce\Blocks\BlockTypes
FeaturedCategory::get_item
Returns the featured category.
Method of the class: FeaturedCategory{}
No Hooks.
Returns
\WP_Term|null
.
Usage
// protected - for code of main (parent) or child class $result = $this->get_item( $attributes );
- $attributes(array) (required)
- Block attributes.
Default: empty array
FeaturedCategory::get_item() FeaturedCategory::get item code WC 9.8.5
protected function get_item( $attributes ) { $id = absint( $attributes['categoryId'] ?? 0 ); $category = get_term( $id, 'product_cat' ); if ( ! $category || is_wp_error( $category ) ) { return null; } return $category; }