我正试图在WooCommerce中获取最近产品的类别名称。我正在使用
[recent_products per_page="12" columns="4"]
最近的产品代码在class-wc-shortcodes.php
中public static function recent_products( $atts ) {
$atts = shortcode_atts( array(
'per_page' => '12',
'columns' => '4',
'orderby' => 'date',
'order' => 'desc'
), $atts );
$query_args = array(
'post_type' => 'product',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'posts_per_page' => $atts['per_page'],
'orderby' => $atts['orderby'],
'order' => $atts['order'],
'meta_query' => WC()->query->get_meta_query()
);
return self::product_loop( $query_args, $atts, 'recent_products' );
}