# LearnDash: Ungraded Essays Dashboard Widget

> Adds a dashboard widget that shows how many essay submissions are waiting to be graded, with a link straight to the list.

- Type: PHP
- Runs: Run everywhere
- Category: [Courses & Community](https://wpide.com/library/category/learning/)
- Tags: learndash, dashboard, quizzes
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/learndash-ungraded-essays-widget/

## Code

```php
if ( ! defined( 'LEARNDASH_VERSION' ) ) {
    return;
}

add_action( 'wp_dashboard_setup', function () {
    if ( ! current_user_can( 'edit_others_posts' ) ) {
        return;
    }

    wp_add_dashboard_widget( 'wpide_ld_essays', 'Essays to grade', function () {
        $count = get_transient( 'wpide_ld_ungraded' );

        if ( false === $count ) {
            $query = new WP_Query( array(
                'post_type'      => 'sfwd-essays',
                'post_status'    => 'not_graded',
                'posts_per_page' => 1,
                'fields'         => 'ids',
            ) );
            $count = (int) $query->found_posts;
            set_transient( 'wpide_ld_ungraded', $count, 15 * MINUTE_IN_SECONDS );
        }

        if ( ! $count ) {
            echo '<p>All caught up: no essays are waiting.</p>';
            return;
        }

        printf(
            '<p style="font-size:1.4em;margin:0 0 .5em"><strong>%1$s</strong> waiting</p><p><a class="button" href="%2$s">Grade essays</a></p>',
            esc_html( number_format_i18n( $count ) ),
            esc_url( admin_url( 'edit.php?post_type=sfwd-essays&post_status=not_graded' ) )
        );
    } );
} );

add_action( 'save_post_sfwd-essays', function () {
    delete_transient( 'wpide_ld_ungraded' );
} );
```

## Notes

Visible to users who can edit others' posts. The count is cached for 15 minutes.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "LearnDash: Ungraded Essays Dashboard Widget" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
