WC_Shortcodes::product_attribute
List products with an attribute shortcode. Example [product_attribute attribute="color" filter="black"].
Method of the class: WC_Shortcodes{}
No Hooks.
Returns
String.
Usage
$result = WC_Shortcodes::product_attribute( $atts );
- $atts(array) (required)
- Attributes.
WC_Shortcodes::product_attribute() WC Shortcodes::product attribute code WC 10.5.0
public static function product_attribute( $atts ) {
$atts = array_merge(
array(
'limit' => '12',
'columns' => '4',
'orderby' => 'title',
'order' => 'ASC',
'attribute' => '',
'terms' => '',
),
(array) $atts
);
if ( empty( $atts['attribute'] ) ) {
return '';
}
$shortcode = new WC_Shortcode_Products( $atts, 'product_attribute' );
return $shortcode->get_content();
}