如何在[recent_products] WooCommerce短代码上显示类别名称?

时间:2015-10-08 16:48:45

标签: php wordpress woocommerce shortcode

我正试图在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' );
}

0 个答案:

没有答案