# Best-Selling Downloads Dashboard Widget

> Lists your five best-selling Easy Digital Downloads products of all time on the dashboard, with their sales count and a link to edit each one.

- Type: PHP
- Runs: Admin only
- Category: [Easy Digital Downloads](https://wpide.com/library/category/edd/)
- Requires: Easy Digital Downloads
- Tags: edd, dashboard, reports, downloads
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/edd-top-downloads-widget/

## Code

```php
add_action( 'wp_dashboard_setup', function () {
    if ( ! function_exists( 'edd_get_download_sales_stats' ) || ! current_user_can( 'view_shop_reports' ) ) {
        return;
    }

    wp_add_dashboard_widget( 'wpide_edd_top', 'Best-selling downloads', function () {
        $ids = get_posts( array(
            'post_type'      => 'download',
            'post_status'    => 'publish',
            'posts_per_page' => 5,
            'fields'         => 'ids',
            'no_found_rows'  => true,
            'meta_key'       => '_edd_download_sales', // phpcs:ignore WordPress.DB.SlowDBQuery
            'orderby'        => 'meta_value_num',
            'order'          => 'DESC',
        ) );

        if ( ! $ids ) {
            echo '<p>' . esc_html( 'No sales yet.' ) . '</p>';
            return;
        }

        echo '<ol>';

        foreach ( $ids as $id ) {
            printf( '<li><a href="%1$s">%2$s</a> &ndash; %3$s</li>', esc_url( get_edit_post_link( $id ) ), esc_html( get_the_title( $id ) ), esc_html( sprintf( '%d sales', edd_get_download_sales_stats( $id ) ) ) );
        }

        echo '</ol>';
    } );
} );
```

## Notes

Uses the sales count EDD stores on each download, so the widget is fast even on large stores.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Best-Selling Downloads 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/
