Yoast\WP\SEO\Generators\Schema
FAQ::generate_question_block
Generate a Question piece.
Метод класса: FAQ{}
Хуков нет.
Возвращает
array. 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() FAQ::generate question block Yoast 28.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 );
}