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

woocommerce_get_loop_display_mode() WC 3.3.0

See what is going to display in the loop.

Хуков нет.

Возвращает

Строку. Either products, subcategories, or both, based on current page.

Использование

woocommerce_get_loop_display_mode();

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

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

Код woocommerce get loop display mode: woocommerce/includes/wc-template-functions.php WC 4.3.1

<?php
function woocommerce_get_loop_display_mode() {
	// Only return products when filtering things.
	if ( wc_get_loop_prop( 'is_search' ) || wc_get_loop_prop( 'is_filtered' ) ) {
		return 'products';
	}

	$parent_id    = 0;
	$display_type = '';

	if ( is_shop() ) {
		$display_type = get_option( 'woocommerce_shop_page_display', '' );
	} elseif ( is_product_category() ) {
		$parent_id    = get_queried_object_id();
		$display_type = get_term_meta( $parent_id, 'display_type', true );
		$display_type = '' === $display_type ? get_option( 'woocommerce_category_archive_display', '' ) : $display_type;
	}

	if ( ( ! is_shop() || 'subcategories' !== $display_type ) && 1 < wc_get_loop_prop( 'current_page' ) ) {
		return 'products';
	}

	// Ensure valid value.
	if ( '' === $display_type || ! in_array( $display_type, array( 'products', 'subcategories', 'both' ), true ) ) {
		$display_type = 'products';
	}

	// If we're showing categories, ensure we actually have something to show.
	if ( in_array( $display_type, array( 'subcategories', 'both' ), true ) ) {
		$subcategories = woocommerce_get_product_subcategories( $parent_id );

		if ( empty( $subcategories ) ) {
			$display_type = 'products';
		}
	}

	return $display_type;
}