WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Авторские Темы для WordPress
функция не описана

wc_get_products() WC 3.0.0

Standard way of retrieving products based on certain parameters.

This function should be used for product retrieval so that we have a data agnostic way to get a list of products.

Args and usage: https://github.com/woocommerce/woocommerce/wiki/wc_get_products-and-WC_Product_Query

Хуков нет.


Массив|stdClass. Number of pages and an array of product objects if paginate is true, or just an array of values.


wc_get_products( $args );
$args(массив) (обязательный)
Array of args (above).

Список изменений

С версии 3.0.0 Введена.

Код wc_get_products() WC 5.4.1

function wc_get_products( $args ) {
	// Handle some BW compatibility arg names where wp_query args differ in naming.
	$map_legacy = array(
		'numberposts'    => 'limit',
		'post_status'    => 'status',
		'post_parent'    => 'parent',
		'posts_per_page' => 'limit',
		'paged'          => 'page',

	foreach ( $map_legacy as $from => $to ) {
		if ( isset( $args[ $from ] ) ) {
			$args[ $to ] = $args[ $from ];

	$query = new WC_Product_Query( $args );
	return $query->get_products();