woocommerce_top_rated_products_widget_args
Usage
add_filter( 'woocommerce_top_rated_products_widget_args', 'wp_kama_woocommerce_top_rated_products_widget_args_filter' );
/**
* Function for `woocommerce_top_rated_products_widget_args` filter-hook.
*
* @param $array
*
* @return
*/
function wp_kama_woocommerce_top_rated_products_widget_args_filter( $array ){
// filter...
return $array;
}
- $array
- -
Where the hook is called
woocommerce_top_rated_products_widget_args
woocommerce/includes/widgets/class-wc-widget-top-rated-products.php 61-76
$query_args = apply_filters( 'woocommerce_top_rated_products_widget_args', array( 'posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', // Left in the args so that the filter above keeps seeing the documented payload; the // query itself is switched to wc_product_meta_lookup in query_top_rated_products(). 'meta_key' => '_wc_average_rating', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key -- Part of the filter payload only; query_top_rated_products() orders through wc_product_meta_lookup instead of joining post meta. 'orderby' => 'meta_value_num', 'order' => 'DESC', 'meta_query' => WC()->query->get_meta_query(), // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Empty unless an extension adds clauses through woocommerce_product_query_meta_query; the same container the shop catalog query uses. 'tax_query' => WC()->query->get_tax_query(), // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query -- Product visibility exclusions are indexed by term_taxonomy_id and are the only way to hide catalog-excluded products. ) );