the_post()
Благодаря функции the_post()
устанавливается глобальная переменная $post с текущей записью и функции [reference_function name=”the_title”]the_title()[/reference_function], [reference_function name=”the_permalink”]the_permalink()[/reference_function] и другие начинают правильно работать, т.к. они как раз её используют.
Примеры
1. Использование the_post()
в основном цикле WordPress.
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
the_title( '<h1>', '</h1>' );
the_content();
}
}
Список изменений
1.5.0 | Introduced. |
Исходный код
Функция расположена в файле: wp-includes/query.php