# Today's Donations in the Admin Bar (GiveWP)

> Shows administrators the number and total of donations received today in the toolbar, linking to GiveWP's donations list, for a quick pulse during campaigns.

- Type: PHP
- Runs: Run everywhere
- Category: [Plugin Integrations](https://wpide.com/library/category/integrations/)
- Tags: givewp, admin-bar, donations
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/give-donor-count-admin-bar/

## Code

```php
add_action( 'admin_bar_menu', function ( $bar ) {
    if ( ! function_exists( 'give_donation_amount' ) || ! current_user_can( 'view_give_reports' ) ) {
        return;
    }

    $data = get_transient( 'wpide_give_today' );

    if ( false === $data ) {
        $ids  = get_posts( array(
            'post_type'     => 'give_payment',
            'post_status'   => 'publish',
            'numberposts'   => 500,
            'fields'        => 'ids',
            'no_found_rows' => true,
            'date_query'    => array( array( 'after' => wp_date( 'Y-m-d 00:00:00' ), 'inclusive' => true ) ),
        ) );
        $data = array( 'count' => count( $ids ), 'total' => 0.0 );
        foreach ( $ids as $id ) {
            $data['total'] += (float) give_donation_amount( $id );
        }
        set_transient( 'wpide_give_today', $data, 5 * MINUTE_IN_SECONDS );
    }

    $total = function_exists( 'give_currency_filter' ) ? give_currency_filter( give_format_amount( $data['total'], array( 'sanitize' => false ) ) ) : number_format_i18n( $data['total'], 2 );

    $bar->add_node( array(
        'id'    => 'wpide-give-today',
        'title' => esc_html( sprintf( 'Today: %1$d donations, %2$s', $data['count'], html_entity_decode( wp_strip_all_tags( $total ) ) ) ),
        'href'  => admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ),
    ) );
}, 90 );

add_action( 'give_complete_donation', function () {
    delete_transient( 'wpide_give_today' );
} );
```

## Notes

Cached for five minutes; counts completed donations only.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Today's Donations in the Admin Bar (GiveWP)" 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/
