Yoast\WP\SEO\Presentations

Indexable_Term_Archive_Presentation::is_multiple_terms_query()protectedYoast 1.0

Checks if term archive query is for multiple terms (/term-1,term-2/ or /term-1+term-2/).

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

Хуков нет.

Возвращает

true|false. Whether the query contains multiple terms.

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

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

Код Indexable_Term_Archive_Presentation::is_multiple_terms_query() Yoast 22.3

protected function is_multiple_terms_query() {
	$query = $this->wp_query_wrapper->get_query();

	if ( ! isset( $query->tax_query ) ) {
		return false;
	}

	if ( \is_wp_error( $this->source ) ) {
		return false;
	}

	$queried_terms = $query->tax_query->queried_terms;

	if ( empty( $queried_terms[ $this->source->taxonomy ]['terms'] ) ) {
		return false;
	}

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