# wp_dashboard_recent_posts()

URL: https://chugunov.pro/api-wordpress/functions/wp_dashboard_recent_posts/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 3.8.0.

## Сигнатура

```php
wp_dashboard_recent_posts( array $args ): bool
```

## Описание

Формирует разделы «Скоро будет опубликовано» и «Недавно опубликовано».

## Параметры

- `$args` `array` — обязательный. Массив аргументов запроса и отображения.
  
  max intЧисло записей для отображения.
  
  status stringСтатус записи.
  
  order stringЗадаёт порядок по возрастанию ('ASC') или по убыванию ('DESC').
  
  title stringЗаголовок раздела.
  
  id stringID контейнера.

## Возвращаемое значение

`bool`

## Исходный код

Файл: `wp-admin/includes/dashboard.php:985`

```php
function wp_dashboard_recent_posts( $args ) {
	$query_args = array(
		'post_type'      => 'post',
		'post_status'    => $args['status'],
		'orderby'        => 'date',
		'order'          => $args['order'],
		'posts_per_page' => (int) $args['max'],
		'no_found_rows'  => true,
		'cache_results'  => true,
		'perm'           => ( 'future' === $args['status'] ) ? 'editable' : 'readable',
	);

	/**
	 * Filters the query arguments used for the Recent Posts widget.
	 *
	 * @since 4.2.0
	 *
	 * @param array $query_args The arguments passed to WP_Query to produce the list of posts.
	 */
	$query_args = apply_filters( 'dashboard_recent_posts_query_args', $query_args );

	$posts = new WP_Query( $query_args );

	if ( $posts->have_posts() ) {

		echo '<div id="' . $args['id'] . '" class="activity-block">';

		echo '<h3>' . $args['title'] . '</h3>';

		echo '<ul>';

		$today    = current_time( 'Y-m-d' );
		$tomorrow = current_datetime()->modify( '+1 day' )->format( 'Y-m-d' );
		$year     = current_time( 'Y' );

		while ( $posts->have_posts() ) {
			$posts->the_post();

			$time = get_the_time( 'U' );

			if ( ! is_int( $time ) ) {
				/* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */
				$date = get_the_date( __( 'M jS Y' ) );
			} elseif ( gmdate( 'Y-m-d', $time ) === $today ) {
				$date = __( 'Today' );
			} elseif ( gmdate( 'Y-m-d', $time ) === $tomorrow ) {
				$date = __( 'Tomorrow' );
			} elseif ( gmdate( 'Y', $time ) !== $year ) {
				/* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */
				$date = date_i18n( __( 'M jS Y' ), $time );
			} else {
				/* translators: Date and time format for recent posts on the dashboard, see https://www.php.net/manual/datetime.format.php */
				$date = date_i18n( __( 'M jS' ), $time );
			}

			// Use the post edit link for those who can edit, the permalink otherwise.
			$recent_post_link = current_user_can( 'edit_post', get_the_ID() ) ? get_edit_post_link() : get_permalink();

			$draft_or_post_title = _draft_or_post_title();
			printf(
				'<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>',
				/* translators: 1: Relative date, 2: Time. */
				sprintf( _x( '%1$s, %2$s', 'dashboard' ), $date, get_the_time() ),
				$recent_post_link,
				/* translators: %s: Post title. */
				esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $draft_or_post_title ) ),
				$draft_or_post_title
			);
		}

		echo '</ul>';
		echo '</div>';

	} else {
		return false;
	}

	wp_reset_postdata();

	return true;
}
```

## История изменений

- 3.8.0 — Introduced.

## Связанные

Использует: [`current_datetime`](https://chugunov.pro/api-wordpress/functions/current_datetime/), [`_draft_or_post_title`](https://chugunov.pro/api-wordpress/functions/_draft_or_post_title/), [`get_the_time`](https://chugunov.pro/api-wordpress/functions/get_the_time/), [`get_the_date`](https://chugunov.pro/api-wordpress/functions/get_the_date/), `WP_Query::__construct`, [`wp_reset_postdata`](https://chugunov.pro/api-wordpress/functions/wp_reset_postdata/), [`date_i18n`](https://chugunov.pro/api-wordpress/functions/date_i18n/), [`current_time`](https://chugunov.pro/api-wordpress/functions/current_time/), [`get_edit_post_link`](https://chugunov.pro/api-wordpress/functions/get_edit_post_link/), [`get_the_ID`](https://chugunov.pro/api-wordpress/functions/get_the_id/), [`current_user_can`](https://chugunov.pro/api-wordpress/functions/current_user_can/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`_x`](https://chugunov.pro/api-wordpress/functions/_x/), [`esc_attr`](https://chugunov.pro/api-wordpress/functions/esc_attr/), [`get_permalink`](https://chugunov.pro/api-wordpress/functions/get_permalink/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).
Используется в: [`wp_dashboard_site_activity`](https://chugunov.pro/api-wordpress/functions/wp_dashboard_site_activity/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/wp_dashboard_recent_posts/
