WP_Query::reset_postdata()publicWP 3.7.0

After looping through a nested query, this function restores the $post global to the current post in this query.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

global $wp_query;
$wp_query->reset_postdata();

Заметки

  • Global. WP_Post. $post Global post object.

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

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

Код WP_Query::reset_postdata() WP 6.8.1

public function reset_postdata() {
	if ( ! empty( $this->post ) ) {
		$GLOBALS['post'] = $this->post;
		$this->setup_postdata( $this->post );
	}
}