Yoast\WP\SEO\Generators\Schema

FAQ::generate_question_block()protectedYoast 1.0

Generate a Question piece.

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

Хуков нет.

Возвращает

Массив. Schema.org Question piece.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->generate_question_block( $question, $position );
$question(массив) (обязательный)
The question to generate schema for.
$position(int) (обязательный)
The position of the question.

Код FAQ::generate_question_block() Yoast 22.4

protected function generate_question_block( $question, $position ) {
	$url = $this->context->canonical . '#' . \esc_attr( $question['id'] );

	$data = [
		'@type'          => 'Question',
		'@id'            => $url,
		'position'       => $position,
		'url'            => $url,
		'name'           => $this->helpers->schema->html->smart_strip_tags( $question['jsonQuestion'] ),
		'answerCount'    => 1,
		'acceptedAnswer' => $this->add_accepted_answer_property( $question ),
	];

	return $this->helpers->schema->language->add_piece_language( $data );
}