Admin & Dashboard PHP Beginner

Show Scheduled Posts on the Dashboard

Add a dashboard widget listing the next 10 scheduled posts, with their publish dates and edit links.

Tested on WordPress 7.1 PHP 8.3 No plugin needed Updated
functions.php 30 lines
add_action( 'wp_dashboard_setup', function (): void {
	if ( ! current_user_can( 'edit_posts' ) ) {
		return;
	}
	wp_add_dashboard_widget( 'nahnu_scheduled_posts', 'Scheduled posts', function (): void {
		$posts = get_posts( [
			'post_status'    => 'future',
			'post_type'      => 'any',
			'posts_per_page' => 10,
			'orderby'        => 'date',
			'order'          => 'ASC',
		] );

		if ( ! $posts ) {
			echo '<p>Nothing scheduled.</p>';
			return;
		}

		echo '<ul>';
		foreach ( $posts as $post ) {
			printf(
				'<li><a href="%s">%s</a> <span style="color:#6B6680">%s</span></li>',
				esc_url( get_edit_post_link( $post ) ),
				esc_html( get_the_title( $post ) ?: '(no title)' ),
				esc_html( get_the_date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $post ) )
			);
		}
		echo '</ul>';
	} );
} );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

The Posts list mixes scheduled posts with everything else. For a content calendar at a glance, this snippet lists what’s coming up next right on the dashboard.

How it works

wp_add_dashboard_widget() registers the widget for anyone who can edit posts. It fetches the next 10 posts of any type with the future status, ordered by publish date, and shows each title with its date and time in your site’s formats, linked to the editor.

Things to watch

  • Posts you can’t edit still appear in the list; the link will tell you if you don’t have permission.
  • If a post shows a date in the past, it missed its schedule. See the “Fix Missed Scheduled Posts” snippet.

How to test it

Schedule a post for tomorrow, then open the dashboard. It should appear in the Scheduled posts widget.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only