Yoast\WP\SEO\Helpers

Current_Page_Helper::count_queried_terms()protectedYoast 1.0

Counts the total amount of queried terms.

Метод класса: Current_Page_Helper{}

Хуков нет.

Возвращает

int. The amoumt of queried terms.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->count_queried_terms();

Код Current_Page_Helper::count_queried_terms() Yoast 22.7

protected function count_queried_terms() {
	$wp_query = $this->wp_query_wrapper->get_main_query();
	$term     = $wp_query->get_queried_object();

	$queried_terms = $wp_query->tax_query->queried_terms;
	if ( \is_null( $term ) || empty( $queried_terms[ $term->taxonomy ]['terms'] ) ) {
		return 0;
	}

	return \count( $queried_terms[ $term->taxonomy ]['terms'] );
}