Scheduled Posts Dashboard Widget
Adds a Dashboard widget that lists the next ten scheduled posts of any type with their publish dates and edit links.
Opens WPIDE on
Code
add_action( 'wp_dashboard_setup', function () {
if ( ! current_user_can( 'edit_posts' ) ) {
return;
}
wp_add_dashboard_widget( 'wpide_scheduled_posts', 'Scheduled Content', function () {
$posts = get_posts( array(
'post_type' => 'any',
'post_status' => 'future',
'numberposts' => 10,
'orderby' => 'date',
'order' => 'ASC',
) );
if ( ! $posts ) {
echo '<p>Nothing is scheduled right now.</p>';
return;
}
echo '<ul>';
foreach ( $posts as $post ) {
$title = get_the_title( $post );
printf(
'<li><a href="%1$s">%2$s</a> – %3$s</li>',
esc_url( (string) get_edit_post_link( $post->ID ) ),
esc_html( '' !== $title ? $title : '(no title)' ),
esc_html( get_the_date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $post ) )
);
}
echo '</ul>';
} );
} );
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.