WC_Shortcodes::related_products
List related products.
Method of the class: WC_Shortcodes{}
No Hooks.
Returns
String.
Usage
$result = WC_Shortcodes::related_products( $atts );
- $atts(array) (required)
- Attributes.
WC_Shortcodes::related_products() WC Shortcodes::related products code WC 10.6.2
public static function related_products( $atts ) {
if ( isset( $atts['per_page'] ) ) {
$atts['limit'] = $atts['per_page'];
}
// @codingStandardsIgnoreStart
$atts = shortcode_atts( array(
'limit' => '4',
'columns' => '4',
'orderby' => 'rand',
), $atts, 'related_products' );
// @codingStandardsIgnoreEnd
ob_start();
// Rename arg.
$atts['posts_per_page'] = absint( $atts['limit'] );
woocommerce_related_products( $atts );
return ob_get_clean();
}